简体   繁体   English

如何配置S3BotoStorage或collectstatic上载到s3存储桶子目录

[英]How do you configure S3BotoStorage or collectstatic to upload to an s3 bucket subdirectory

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? 有没有一种方法可以将django的collectstatic命令配置为上载到s3存储桶中的子目录,而不仅仅是上一级目录?

Thanks 谢谢

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 . 如果您使用的是django-storages S3BotoStorage引擎,则有一个名为AWS_LOCATION的设置变量,它将为您在AWS_STORAGE_BUCKET_NAME指定的S3存储桶设置键前缀(等效于子目录)。

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. 请注意,我还没有将它与collectstatic ,但是考虑到它和存储引擎之间的分离,我看不到它如何不起作用。

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM