I have a Django project setup with S3 as the static file host.
settings.py
AWS_STORAGE_BUCKET_NAME = 'project-1'
conn = boto.connect_s3()
STATICFILES_STORAGE = 'storages.backends.s3boto.S3BotoStorage'
S3_URL = 'http://project-1.s3.amazonaws.com/'
STATIC_URL = S3_URL
And then I make references to static files in my templates using the template tag, like so:
<script src="{% static 'js/jquery.payment.js' %}"></script>
This renders correctly inside the browser, but the URL has 3 other parameters on them, Signature
, Expires
, and AWSAccessKeyId
. The latter two do not have any affect on the file, but accessing the file with the rendered Signature
value results in an InvalidAccessKeyId error, with the message "The AWS Access Key Id you provided does not exist in our records."
Manually taking away the Signature
parameter lets me access the file fine. Taking away all three parameters is fine. Taking away either of the latter two parameters results in an error: "Query-string authentication requires the Signature, Expires and AWSAccessKeyId parameters".
Amazon's S3 documentation reveals that query string authentication is used to allow you access to files that you would normally need authentication to, and that the Expires
parameter is not, as I thought it was, related to caching. Since it appears that these files don't require any authentication (i.e. I can access them when no URL parameters are present), I need help either:
Signature
valueSet AWS_QUERYSTRING_AUTH = False
.
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