如何在Django中配置AWS4 S3授权? [英] How to configure AWS4 S3 Authorization in Django?
问题描述
我为Frankfurt
区域配置了S3
存储桶.尽管我基于Django
的服务能够将文件写入存储桶,但是每当它尝试读取文件时,都会出现InvalidRequest
错误,提示升级授权机制:
I configurred S3
bucket for Frankfurt
region. Though my Django
-based service is able to write files to the bucket, whenever it tried to read them there's InvalidRequest
error telling to upgrate authorization mechanizm:
<Error>
<Code>InvalidRequest</Code>
<Message>
The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
</Message>
<RequestId>17E9629D33BF1E24</RequestId>
<HostId>
...
</HostId>
</Error>
此错误的原因是在我不正确的存储后端实现中造成的,还是由存储桶不支持较早的AWS3
授权方法引起的?
Is the cause for this error burried in my incorrect implementation of storage backend or is this caused by bucket not supporting older AWS3
method of authorization?
如何在Django中配置S3Boto3Storage
以使用AWS4
授权?我找不到有关此主题的任何权威文档.
How to configure S3Boto3Storage
in Django to use AWS4
authorization? I can't find any definitive documentation on this topic.
推荐答案
由于您提到了S3Boto3Storage
后端,因此我假设您使用的是django-storages,而不是编写自己的实现.有一个设置可以让您指定要使用的签名版本,AWS_S3_SIGNATURE_VERSION = 's3v4'
您可以在此处
Since you mentioned the S3Boto3Storage
backend, I'm assuming you're using django-storages rather than writing your own implementation. There's a setting that lets you specify which signature version to use, AWS_S3_SIGNATURE_VERSION = 's3v4'
you can find the full list of settings for S3 here https://django-storages.readthedocs.io/en/latest/backends/amazon-S3.html#settings
这篇关于如何在Django中配置AWS4 S3授权?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!