简体   繁体   English

django-storages boto3 访问私有文件的文件 url

[英]django-storages boto3 accessing file url of a private file

I'm trying to get the generated URL of a file in a test model I've created, and I'm trying to get the correct url of the file by: modelobject.file.url which does give me the correct url if the file is public, however if the file is private it does not automatically generate a signed url for me, how is this normally done with django-storages?我正在尝试在我创建的测试模型中获取文件的生成 URL,并且我正在尝试通过以下方式获取文件的正确 url: modelobject.file.url如果文件是公开的,但是如果文件是私有的,它不会自动为我生成一个签名的 url,这通常是如何使用 django-storages 完成的?

Is the API supposed to automatically generate a signed url for private files? API 是否应该为私有文件自动生成签名 url? I am getting the expected Access Denied Page for 'none' signed urls currently, and need to get the signed 'volatile' link to the file.我目前正在获得“无”签名网址的预期访问拒绝页面,并且需要获得文件的签名“易失性”链接。

Thanks in advance提前致谢

I've figured out what I needed to do,我已经弄清楚我需要做什么,

in the Private Storage class, I forgot to put custom_domain = False originally left this line off, because I did not think I needed it however you absolutely do in order to generate signed urls automatically.在 Private Storage 类中,我忘了把custom_domain = False最初离开这条线,因为我认为我不需要它,但是为了自动生成签名的 url,你绝对这样做。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 SignatureDoesNotMatch - Boto3 Django 存储 - SignatureDoesNotMatch - Boto3 Django-storages django-storages和boto配置不正确 - django-storages and boto ImproperlyConfigured Django-storages 强制上传文件 - Django-storages force file to upload 使用 django-audiofield、django-storages、boto 将音频文件上传到 s3。 django-storages 这个后端不支持绝对路径错误 - Uploading a audio file to s3 with django-audiofield, django-storages, boto. django-storages This backend doesn't support absolute paths error 使用django-storages boto3将文件动态上传到不同的s3存储桶中 - Upload files dynamically into different s3 buckets with django-storages boto3 ImportError:没有名为自定义存储的模块 - django-storages boto - ImportError: No module named custom storages - django-storages boto 使用 Django 存储删除 Amazon S3 中的文件 - Remove a file in Amazon S3 using Django-storages 移动文件而无需在django-storages和S3中打开 - Move file without opening in django-storages and S3 为什么 S3(与 boto 和 django-storages 一起使用)甚至为公共文件提供签名 url? - Why does S3 (using with boto and django-storages) give signed url even for public files? 使用django-storages / boto在本地收集静态作品,但不在Heroku上收集 - Collect static works locally but no on Heroku using django-storages/boto
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM