Skip to main content

Django Aliyun OSS (Object Storage Service) storage

Project description

Django AliCloud OSS Storage


django-oss-storage provides a Django AliCloud OSS file storage.

Features


  • Django file storage for AliCloud OSS

  • Django static file storage for AliCloud OSS

  • Works in Python 2 & 3

Installation


  • Install

$ pip install django-oss-storage
  • Add 'django_oss_storage' to your INSTALLED_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.

STATICFILES_STORAGE = 'django_oss_storage.backends.OssStaticStorage'



DEFAULT_FILE_STORAGE = 'django_oss_storage.backends.OssMediaStorage'

Authentication settings


Use the following settings to authenticate with AliCloud OSS.

# AliCloud access key ID

OSS_ACCESS_KEY_ID = <Your Access Key ID>



# AliCloud access key secret

OSS_ACCESS_KEY_SECRET = <Your Access Key Secret>

Storage settings


For public or public-read buckets, storage urls will be bucket_name.endpoint/key format

For private buckets, storage urls will be signed url. The expires time can be set by OSS_EXPIRE_TIME as environment variable or as Django settings. The default value for OSS_EXPIRE_TIME is 30 days.

OSS_EXPIRE_TIME = <Expire Time in Seconds>

File storage settings


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/'

Staticfiles storage settings


All of the file storage settings are available for the staticfiles storage.

# The default location for your static files

STATIC_URL = '/static/'

staticfiles provides command ‘collectstatic’. Run following command to collect all sub-folder ‘static’ of each app

and upload to STATIC_URL.

$ python manage.py collectstatic

Testing


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:

$ export OSS_ACCESS_KEY_ID=<AccessKeyId>

$ export OSS_ACCESS_KEY_SECRET=<AccessKeySecret>

$ export OSS_BUCKET_NAME=<bucket>

$ export OSS_ENDPOINT=<endpoint>

Support and announcements


Downloads and bug tracking can be found at the main project website.

License


Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django5.0-oss-storage-1.1.1.tar.gz (9.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django5.0_oss_storage-1.1.1-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file django5.0-oss-storage-1.1.1.tar.gz.

File metadata

  • Download URL: django5.0-oss-storage-1.1.1.tar.gz
  • Upload date:
  • Size: 9.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.0.0 CPython/3.8.9

File hashes

Hashes for django5.0-oss-storage-1.1.1.tar.gz
Algorithm Hash digest
SHA256 53e91ce6e1d41a8afcbc6b4d4aaa06f41f3f0a5c47daab180ca04958e9d626a4
MD5 a82280397aac81de7f93709ae1157d90
BLAKE2b-256 681059ec129195b4d32ae228d12ea11704ece708e8b05e710647b17c98fd7068

See more details on using hashes here.

File details

Details for the file django5.0_oss_storage-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django5.0_oss_storage-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 c972ee93ca489b9c623a3ce8ebe6341dc2160f1bea9f638612ae924edd810887
MD5 998953f4a1b401ecc8a07260a88b8647
BLAKE2b-256 3e3b3acd421fe2a86e99dac898a8f88b0c2e02237f0bd7ad1156712e87b88e64

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page