我使用djangos3direct将文件上传到S3存储桶中
我使用以下配置
AWS_SECRET_ACCESS_KEY = ''
AWS_ACCESS_KEY_ID = ''
AWS_STORAGE_BUCKET_NAME = ''
这些值是在IAM管理控制台中生成的
我设置bucket,CORS配置如下
^{pr2}$但是,当我尝试在Django admin中上载文件时,会出现以下错误:
XMLHttpRequest cannot load https://s3.amazonaws.com/<bucketname>. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8000' is therefore not allowed access.
同样的问题,除了我一直从AWS得到301。经过一番挖掘,我发现了这条评论comment:
所以我用与Kanhaiya相反的方法来解决这个问题。我把
S3DIRECT_REGION
放在settings
中,删除它(直接查询s3.amazonaws.com
)后,问题就解决了!在我在django-s3direct中遇到了同样的问题,甚至在添加了CORS值之后。对我来说,在添加了 S3DIRECT_地区='ap-东南-1' 您可以从here中选择您的区域
相关问题 更多 >
编程相关推荐