如何配置S3BotoStorage或collectstatic上传到S3存储子目录 [英] How do you configure S3BotoStorage or collectstatic to upload to an s3 bucket subdirectory
问题描述
有没有一种方法来配置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存储你的<$ C $指定密钥preFIX(相当于子目录) C> AWS_STORAGE_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.
这篇关于如何配置S3BotoStorage或collectstatic上传到S3存储子目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!