django - Django 存储和 Boto3 未从 AWS S3 检索媒体
问题描述
我正在使用开发服务器来测试使用 Django 存储和 Boto3 从 AWS S3 上传和检索静态文件。文件上传有效,但我无法检索文件。
这就是我得到的:
当我在另一个选项卡中查看 URL 时,我得到了这个
**This XML file does not appear to have any style information associated with it. The document tree is shown below.**
<Error>
<Code>IllegalLocationConstraintException</Code>
<Message>The me-south-1 location constraint is incompatible for the region specific endpoint this request was sent to.</Message>
<RequestId></RequestId>
<HostId></HostId>
</Error>
我还用我自己的凭证和 IAM 用户配置了 settings.py
AWS_ACCESS_KEY_ID = <key>
AWS_SECRET_ACCESS_KEY = <secret-key>
AWS_STORAGE_BUCKET_NAME = <bucket-name>
AWS_DEFAULT_ACL = None
AWS_S3_FILE_OVERWRITE = False
AWS_S3_REGION_NAME = 'me-south-1'
AWS_S3_USE_SSL = True
AWS_S3_VERIFY = False
DEFAULT_FILE_STORAGE = 'storages.backends.s3boto3.S3Boto3Storage'
解决方案
请检查您的 AWS Identity & Access Management Console (IAM) 是否为您的访问密钥分配了适当的 S3 权限。
此外,请确保您已安装 AWS CLI 并在您的计算机中设置您的凭证。
您可以尝试运行以下命令并进行验证。
$ aws s3 ls
2018-12-11 17:08:50 my-bucket
2018-12-14 14:55:44 my-bucket2
参考:https ://docs.aws.amazon.com/cli/latest/userguide/cli-services-s3-commands.html
推荐阅读
- linux - 如何在运行时加载 strongswan 插件
- jquery - 删除已从另一个下拉菜单中选择但未使用 value 属性的下拉值
- python - 找出一个元组是否包含在另一个在 Python 中重复的元组中
- assembly - x86 处理器中的同胞字节是如何形成的?
- javascript - POST 响应后页面内容未更新
- flutter - 循环使用 Flutter 生成 2 列的列表
- python - 如何禁用柱状列中的文本换行?
- cordova - ionic - 为 web 构建,index.html 寻找不存在的文件
- python - Python 3.7:无法在 Windows 10 的 venv 中安装 gmpy2
- symfony - 带有 Symfony 4.4.1 的 Kayue\WordpressBundle:在链配置的命名空间 App\Entity 中找不到类 XXX