This is strange. I have mix of public as well as private files. I want normal urls in public files, and signed urls in private files.
I tried to change AWS_QUERYSTRING_AUTH to False
as I see by default, it's True in django-storages.
But, when I change it, my private files url is not signed (thus not accessible).
May be I am missing something here. What can be solution?
Thanks in advance.
S3 pre-signed URLs are a form of an S3 URL that temporarily grants restricted access to a single S3 object to perform a single operation — either PUT or GET — for a predefined time limit. To break it down: It is secure — the URL is signed using an AWS access key.
There is an access check on the S3 side but that only checks whether the signer entity is allowed to get the file. You can remove that permission but that invalidates all signed URLs. Signed URLs provide secure a way to distribute private content without streaming them through the backend.
All objects and buckets are private by default. However, you can use a presigned URL to optionally share objects or allow your customers/users to upload objects to buckets without AWS security credentials or permissions. You can use presigned URLs to generate a URL that can be used to access your Amazon S3 buckets.
In the Amazon S3 console, the maximum expiration time for a presigned URL is 12 hours from the time of creation.
AWS_QUERYSTRING_AUTH
sets the default behavior, but you can override it when you create an instance of S3BotoStorage
, by passing in an additional argument to the initializer:
S3BotoStorage(bucket="foo", querystring_auth=False)
So if you have one bucket private and another bucket public, you can set the querystring_auth
argument appropriately and get your desired behavior.
put this in your settings.py
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