Django AliCloud OSS Storage =========================
django-oss-storage provides a Django AliCloud OSS file storage.
- Django file storage for AliCloud OSS
- Django static file storage for AliCloud OSS
- Works in Python 2 & 3
- Install
- Add
'django_oss_storage'
to yourINSTALLED_APPS
setting - Set your
DEFAULT_FILE_STORAGE
setting to"django_oss_storage.backends.OssMediaStorage"
- Set your
STATICFILES_STORAGE
setting to"django_oss_storage.backends.OssStaticStorage"
- Configure your AliCloud OSS settings (Refer below).
Use the following settings for file storage.
Use the following settings to authenticate with AliCloud OSS.
Use the following settings to configure AliCloud OSS file storage.
# The name of the bucket to store files in
OSS_BUCKET_NAME = <Your bucket name>
# The URL of AliCloud OSS endpoint
# Refer https://www.alibabacloud.com/help/zh/doc-detail/31837.htm for OSS Region & Endpoint
OSS_ENDPOINT = <Your access endpoint>
# The default location for your files
MEDIA_URL = '/media/'
All of the file storage settings are available for the staticfiles storage.
staticfiles provides command 'collectstatic'. Run following command to collect all sub-folder 'static' of each app and upload to STATIC_URL.
First set the required AccessKeyId, AccessKeySecret, endpoint and bucket information for the test through environment variables (Do not use the bucket for the production environment). Take the Linux system for example:
Downloads and bug tracking can be found at the main project website.
- MIT.