New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Files not being created with the proper ACL #927
Comments
Version 1.10 broke S3 for me entirely, possibly because of an ACL issue (I haven't dug into it, but it would check out--I'm getting PutObject denied which would happen if there's an ACL other than None given my bucket policies). Rolling back to 1.9.1 fixes it. |
Maybe related to AWS_DEFAULT_ACL being replaced, i.e.
instead of
You might want to have a look at https://github.com/jschneier/django-storages/blob/master/CHANGELOG.rst quite a few breaking changes in 1.10. |
I have run into this too using a fix from #382 custom_storages.py
In e37912b, support for the class attribute
Adding the following to settings.py fixed the issue for me
Edit: on closer inspection, class attributes that can override settings.py are located in S3Boto3Storage.get_default_settings. There doesn't seem to be any explicit documentation on them. |
How do you pass that when creating an instance? Did 1.10 introduce anything aside from dropping a bunch of very useful features? ArchiveStorage = S3Boto3Storage(
bucket_name=f"archives.{settings.SITE_SLUG}",
default_acl="private",
querystring_auth=True,
querystring_expire=3600 * 48,
) |
On closer inspection, I don't think that features were dropped... the API was changed that's all. See S3Boto3Storage.get_default_settings and BaseStorage for how to override settings.py-based configuration when creating an instance. Try setting |
@rohfle Thanks! |
Hi, maybe the documentation could be updated to explain how to properly override the |
@Ouradze sure. Is there anything in particular you are missing. The simplest example of porting ACL is this AWS_S3_OBJECT_PARAMETERS = {
'ACL': ...your acl setting here
} Overriding will allow you to do things like use different parameter values based on filename. |
Thanks @jschneier ! I used this for now as we have multiple classes with different ACLs. |
Hello, Thank you all for your feedback. I read the changelog regarding from storages.backends.s3boto3 import S3Boto3Storage
from django.conf import settings
class StaticStorage(S3Boto3Storage):
location = settings.STATIC_LOCATION
def get_object_parameters(self, name):
s3_object_params = {
"ACL": "public-read"
}
return {**s3_object_params, **self.object_parameters.copy()}
class PublicMediaStorage(S3Boto3Storage):
location = settings.PUBLIC_MEDIA_LOCATION
file_overwrite = False
def get_object_parameters(self, name):
s3_object_params = {
"ACL": "public-read"
}
return {**s3_object_params, **self.object_parameters.copy()} I noticed that |
I have release 1.10.1 that restores handling of |
@jschneier Thanks Josh, we both simultaneously hate and love you. Appreciate all the hard work on django-storages! Love not hate. 😀 |
Hello,
I am using django-storages with s3. I've noticed that files are not being created in my s3 bucket through storages with the proper ACL, though I'm certain that this was working just a little while ago. Can you help me understand what I'm doing wrong? Thanks!
My s3 bucket settings:
AWS console s3 settings images
The text was updated successfully, but these errors were encountered: