Amazon s3在使用urllib2(python)的gif文件时出现问题
我们正在使用urllib2将图像上载到s3:Amazon s3在使用urllib2(python)的gif文件时出现问题,python,django,amazon-s3,urllib2,Python,Django,Amazon S3,Urllib2,我们正在使用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_ACC
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文件加载正确,但当我们转到Amazon上的文件URL时,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>
有人知道为什么吗?s3文件夹的权限设置正确吗?考虑到我可以使用完全相同的代码将JPG上传到同一个bucket/place,并以相同的方式访问,我认为是这样的。权限是否允许访问JPG文件,但不允许访问GIF?据我所知,不是这样的:P