Django Admin S3 私有媒体文件

发布于 2025-01-16 16:48:37 字数 396 浏览 3 评论 0原文

当使用下面的私有媒体 django-storages 类时。当我在管理中查看上传的文件时,它不会生成 URL 查询字符串授权参数。

from django.conf import settings
from storages.backends.s3boto3 import S3Boto3Storage


class PrivateMediaRootTenantedS3Boto3Storage(S3Boto3Storage):
    auto_create_bucket = True
    default_acl = "private"
    file_overwrite = False
    custom_domain = False

When using the private media django-storages class below. When I view the uploaded file in the admin it does not generate the URL Query String Authorization parameters.

from django.conf import settings
from storages.backends.s3boto3 import S3Boto3Storage


class PrivateMediaRootTenantedS3Boto3Storage(S3Boto3Storage):
    auto_create_bucket = True
    default_acl = "private"
    file_overwrite = False
    custom_domain = False

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

身边 2025-01-23 16:48:37

问题是 django-cookiecutterAWS_QUERYSTRING_AUTH 值设置为 False其默认值为True

有关需要为 Falsecustom_domain 变量的其他参考信息,请参阅 此问题和答案

The issue was django-cookiecutter sets the AWS_QUERYSTRING_AUTH value to False when its default is True.

Additional reference about the custom_domain variable needing to be False can be found in this question and answer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文