Why does S3 (using with boto and django-storages)

2019-02-06 15:45发布

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.

3条回答
Deceive 欺骗
2楼-- · 2019-02-06 16:15

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.

查看更多
孤傲高冷的网名
3楼-- · 2019-02-06 16:16

Another way to get around this is to set AWS_S3_CUSTOM_DOMAIN in your settings. @see: https://github.com/jschneier/django-storages/blob/master/storages/backends/s3boto.py#L478

(tested with boto==2.38.0 and django-storages-redux==1.3)

查看更多
We Are One
4楼-- · 2019-02-06 16:20

put this in your settings.py

AWS_QUERYSTRING_AUTH = False
查看更多
登录 后发表回答