Reputation: 51
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.
Upvotes: 5
Views: 2164
Reputation: 1
Do you notice that a quote is missing here? AWS_QUERYSTRING_EXPIRE = 3600'
It should be: AWS_QUERYSTRING_EXPIRE = '3600'
Upvotes: 0
Reputation: 666
The answer is that django-storages querystrings are not compatible with custom domains.
Upvotes: 4