So i have django-queued-storages
+ django-storages
+ boto
in my project and i want to upload my pdf files to S3 and immediately make them private.
i have tried many approaches with no results them being:
publication_storage = QueuedStorage(
local='django.core.files.storage.FileSystemStorage',
remote='storages.backends.s3boto.S3BotoStorage',
remote_options=dict(acl="private")
)
and it didn't put my file as private.
i also tried something like this based on http://www.gyford.com/phil/writing/2012/09/26/django-s3-temporary.php:
k = boto.s3.key.Key(bucket)
k.key = settings.MEDIA_DIRECTORY + self.private_file
k.set_acl('private')
all of these still kept my uploaded PDF acessible to the outside.
Can anyone help me out? maybe a full example so i can try it, i have tried lots of things that i found on google with no luck yet
After going back and forth with you, this is what worked.
Since you have both media
and static
under the same bucket, make the bucket private. Then only make the static
folder public by right clicking on the folder in the S3 admin panel and clicking on 'Make public'.
As for the media
folder, your second block of code should suffice
k = boto.s3.key.Key(bucket)
k.key = settings.MEDIA_DIRECTORY + self.private_file
k.set_acl('private')
This was also educational for me as I have two separate buckets on S3, one for uploads and one for static. So naturally I didn't run into this problem.
Good luck to you.