Skip to main content

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>

# When you configed bucket with CNAME(custom domain), provide OSS_CNAME for signing url
# OSS_ENDPOINT will still be used for puting files
# https://help.aliyun.com/document_detail/31836.html
OSS_CNAME = <Your bucket custom domain>

# 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

Metadata

Release files for ifournight-django-oss-storage 1.1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ifournight-django-oss-storage 1.1.2
File Size Uploaded Provenance
ifournight-django-oss-storage-1.1.2.tar.gz 9.6 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ifournight-django-oss-storage 1.1.2
File Interpreter ABI Platform
ifournight_django_oss_storage-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 16.5 kB

Release files / ifournight-django-oss-storage-1.1.2.tar.gz

Download URL ifournight-django-oss-storage-1.1.2.tar.gz
Size 9.6 kB
Tags Source
SHA-256 checksum
How to use checksums
62d4b7590f362654671d3cc72b147de1367551101006216063df959a52a1260b
BLAKE2b-256 checksum
How to use checksums
4c4a46bc0e2822bae17e369b5522f24b37753e3ba2a453336c809329438d5967
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.4

Release files / ifournight_django_oss_storage-1.1.2-py3-none-any.whl

Download URL ifournight_django_oss_storage-1.1.2-py3-none-any.whl
Size 6.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fc12b32f08a27561991492f922173c7aac7a335bda26e80aa18fd7776c196c37
BLAKE2b-256 checksum
How to use checksums
7bbe581ee22d122c8db4b5f5dae7e12e54b15651ab70f9435009fc97c92e90ac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.7.4

Security for ifournight-django-oss-storage 1.1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page