etianen / django-s3-storage

Django Amazon S3 file storage.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Issues configuring AWS_S3_ENDPOINT_URL

evil-toast-nom-nom opened this issue · comments

TL;DR;
When using trying to access a static file, you get an error:

The <your region name> location constraint is incompatible for the region specific endpoint this request was sent to.

Set the variable: AWS_S3_ENDPOINT_URL_STATIC in stead of AWS_S3_ENDPOINT_URL to comply with this standard. e.g.

AWS_S3_ENDPOINT_URL_STATIC = '"https://s3.<region code>.amazonaws.com"

Usage:
Static files for a Django application.

When using a non us-west-1 region, it seems like the URL isn't being rewritten to comply with this standard.

As a result you will see an error message like the below from S3 when trying to open a static file.
The af-south-1 location constraint is incompatible for the region specific endpoint this request was sent to.

<Error>
<Code>IllegalLocationConstraintException</Code>
<Message>The <region code> location constraint is incompatible for the region specific endpoint this request was sent to.</Message>
<RequestId>xxxxx</RequestId>
<HostId>xxxxxx</HostId>
</Error>

According to this question. It seems like you should be able to configure the below setting:

# The full URL to the S3 endpoint. Leave blank to use the default region URL.
AWS_S3_ENDPOINT_URL = ""

Unfortunately it seems like here a suffix is added to the setting to load.
This causes an issue when specifying AWS_S3_ENDPOINT_URL as directed.
By specifying AWS_S3_ENDPOINT_URL_STATIC you are able to set the AWS_S3_ENDPOINT_URL variable properly.

Thanks for your quick response.

Agreed, it's documented there.

Perhaps a reference here and/or here would make it more discoverable.

Have a great day.