Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django Storages AWS_QUERYSTRING_AUTH Not Working

I have been trying to solve this and so far unable to do so on my own. There are several different post in regards to the reverse of my issue as to not wanting authentication in the S3 url.

I am using Django-Storages with the following in my settings.py:

AWS_STORAGE_BUCKET_NAME = 'testbucket'

AWS_ACCESS_KEY_ID = 'xxxxx'

AWS_SECRET_ACCESS_KEY = 'xxxxxx'

AWS_QUERYSTRING_AUTH = True

AWS_QUERYSTRING_EXPIRE = 3600'

from datetime import datetime, timedelta

AWS_HEADERS = {
    'Expires': (datetime.now() + timedelta(days=365*10)).strftime('%a, %d %b %Y 00:00:00 GMT')
}

AWS_S3_SECURE_URLS = True

AWS_S3_CUSTOM_DOMAIN = '%s.s3.amazonaws.com' % AWS_STORAGE_BUCKET_NAME

MEDIA_URL = "https://%s/" % AWS_S3_CUSTOM_DOMAIN

DEFAULT_FILE_STORAGE = 'storages.backends.s3boto.S3BotoStorage'

No issues saving or listing files but none of the urls have the authentication query string.

An example of the url being returned.

Any help is much appreciated.

like image 407
Kent Hudson Avatar asked Sep 26 '22 14:09

Kent Hudson


1 Answers

The answer is that django-storages querystrings are not compatible with custom domains.

like image 61
Faris Sbahi Avatar answered Sep 30 '22 06:09

Faris Sbahi