如何配置S3BotoStorage或collectstatic上传到S3存储子目录子目录、S3BotoStorage、collectstatic

由网友(我在回忆里等你)分享简介:有没有一种方法来配置Django的collectstatic命令上传到一个子目录中的S3存储桶,而不是仅仅在顶层目录?Is there a way to configure django's collectstatic command to upload to a subdirectory in an s3 buck...

有没有一种方法来配置Django的collectstatic命令上传到一个子目录中的S3存储桶,而不是仅仅在顶层目录?

Is there a way to configure django's collectstatic command to upload to a subdirectory in an s3 bucket, rather than just the top level directory?

感谢

推荐答案

如果您使用的是 S3BotoStorage 引擎从 Django的存储器然后有称为设置变量 AWS_LOCATION 这将设置为S3存储你的 AWS_STORAG​​E_BUCKET_NAME 。

If you're using the S3BotoStorage engine from django-storages then there's a settings variable called AWS_LOCATION which will set the key prefix (equivalent to subdirectory) for the S3 bucket you specify in AWS_STORAGE_BUCKET_NAME.

请注意,我没有用过这个与 collectstatic ,但我看不出它不会工作给予它和存储引擎之间的距离。

Note that I haven't used this with collectstatic, but I can't see how it wouldn't work given the separation between it and the storage engines.

阅读全文

相关推荐

最新文章