0

我们正在使用 urllib2 将图像上传到 s3:

img_url = pic
imgData = urllib2.urlopen(img_url).read()
unipart.coverart = store_in_s3_partpic(name, imgData)


def store_in_s3_partpic(name, content):
    conn = S3Connection(settings.AWS_ACCESS_KEY_ID, settings.AWS_SECRET_ACCESS_KEY)
    pathtofile = "partpics/%s" % (name)
    b = conn.create_bucket('bucketname')
    k = Key(b)
    path = "/media/" + pathtofile
    k.key = path
    k.set_contents_from_string(content)
    k.set_acl("public-read")
    return pathtofile

JPG 文件正确加载,但 GIF 文件在我们转到 Amazon 上的文件 URL 时始终出现以下错误:

This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Code>AccessDenied</Code>
<Message>Access Denied</Message>
<RequestId>E9482112F0EBAAD7</RequestId>
<HostId>
9Xoh6fuKdsDIwYASEg64VHt5sxw1aYXmmBGtacsG1JYMgr18GUooZReB5WyRN1TW
</HostId>
</Error>

有谁知道为什么?

4

0 回答 0