我们正在使用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文件始终会出现以下错误:
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>
有谁知道为什么?