简体   繁体   中英

Django and Amazon S3

Hi everybody I'm trying to deploy my website and I'm using AWS S3 to store the images that a user upload. Anyway when I run my website the images don't show up and if I use the inspector I keep having a 404 error. I don't know what I'm doing wrong. Hope someone can help me, thanks!

And if I open the image in another tab I get this:

This XML file does not appear to have any style information associated with it. The document tree is shown below.

<Error>
<Code>InvalidRequest</Code>
<Message>
The authorization mechanism you have provided is not supported. Please use AWS4-HMAC-SHA256.
</Message>
<RequestId>6F8B0E05F6191EDA</RequestId>
<HostId>
kwKWtzyw9qjLigGQY/QLLBQjfpVmGDKwlt1fUd4Q1pA+LnZ12prqUri7q1MGpc8oAihXFZU08TA=
</HostId>
</Error>

The bucket region is UE (London) eu-west-2

This is the CORS configuration I used:

<?xml version="1.0" encoding="UTF-8"?>
<CORSConfiguration xmlns="http://s3.amazonaws.com/doc/2006-03-01/">
<CORSRule>
    <AllowedOrigin>*</AllowedOrigin>
    <AllowedMethod>GET</AllowedMethod>
    <AllowedMethod>POST</AllowedMethod>
    <AllowedMethod>PUT</AllowedMethod>
    <AllowedHeader>*</AllowedHeader>
</CORSRule>
</CORSConfiguration>

In settings.py , set AWS_S3_SIGNATURE_VERSION to s3v4 will work.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM