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.
The answer is that django-storages querystrings are not compatible with custom domains.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With