为什么S3(与伯特和Django的存储器使用)给标识的URL甚至公开的文件? [英] Why does S3 (using with boto and django-storages) give signed url even for public files?

查看:139
本文介绍了为什么S3(与伯特和Django的存储器使用)给标识的URL甚至公开的文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是奇怪的。我有公众的混音以及私人文件。我想在公开的文件正常的网址,并在私人文件签订的URL。

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.

我试图改变 AWS_QUERYSTRING_AUTH为False 我在默认情况下看到的,这是真的在Django的存储器。

I tried to change AWS_QUERYSTRING_AUTH to False as I see by default, it's True in django-storages.

但是,当我改变它,我的私人文件的URL未签名(因此无法访问)。

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?

在此先感谢。

推荐答案

AWS_QUERYSTRING_AUTH 设置默认行为,但你可以重写它,当你创建一个实例 S3BotoStorage 中,通过传递一个额外的参数来初始化:

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)

所以,如果你有一个水桶私人和另一个斗市民,则可以设置适当的 querystring_auth 参数,并得到你想要的行为。

So if you have one bucket private and another bucket public, you can set the querystring_auth argument appropriately and get your desired behavior.

这篇关于为什么S3(与伯特和Django的存储器使用)给标识的URL甚至公开的文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆