问题
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>
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?
How to configure S3Boto3Storage
in Django to use AWS4
authorization? I can't find any definitive documentation on this topic.
回答1:
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
来源:https://stackoverflow.com/questions/59543979/how-to-configure-aws4-s3-authorization-in-django