Skip to main content

Django5 storage backend for Aliyun OSS

Project description

Django 5 阿里云 OSS 存储

用于阿里云 OSS(对象存储服务)的 Django 存储后端。

安装

pip install django5-aliyun-oss

配置

在您的 Django settings.py INSTALLED_APPS 中添加以下设置:

INSTALLED_APPS = [
    ...
    'django5_aliyun_oss',
    ...
]

在您的 Django settings.py 中添加以下设置:

ALIYUN_OSS = {
    'ACCESS_KEY_ID': '您的访问密钥ID',
    'ACCESS_KEY_SECRET': '您的访问密钥密码',
    'ENDPOINT': '您的终端节点',
    'BUCKET_NAME': '您的存储桶名称',
    'URL_EXPIRE_SECONDS': 3600,  # 可选,默认为3600
}

# 设置为默认存储器
STORAGES = {
    'default': {
        'BACKEND': 'django5_aliyun_oss.storage.AliyunOSSStorage',
    },
    'staticfiles': {
        'BACKEND': 'django.contrib.staticfiles.storage.StaticFilesStorage',
    }
}

使用

from django.db import models

class YourModel(models.Model):
    file = models.FileField(upload_to='uploads/')
    image = models.ImageField(upload_to='images/')

特性

  • 兼容 Django 5.0+
  • 支持所有基本文件操作
  • 处理文件删除
  • 可配置的上传路径
  • 支持静态文件存储

许可证

MIT 许可证

贡献

欢迎贡献!请随时提交拉取请求。

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-aliyun-oss-1.1.1.tar.gz (5.1 kB view details)

Uploaded Source

Built Distribution

django5_aliyun_oss-1.1.1-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file django5-aliyun-oss-1.1.1.tar.gz.

File metadata

  • Download URL: django5-aliyun-oss-1.1.1.tar.gz
  • Upload date:
  • Size: 5.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.0

File hashes

Hashes for django5-aliyun-oss-1.1.1.tar.gz
Algorithm Hash digest
SHA256 60821f9a8ac65a6150a1b92271054cdb2111d09cacc2a20d9946d62ee37a4224
MD5 a052d92a046b9576ffa9edc47366d2c5
BLAKE2b-256 9c2f03fb7e60115a8bd258f0b412d446cf9c70cc9cb6432eb3c9ef11ae4928c9

See more details on using hashes here.

File details

Details for the file django5_aliyun_oss-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django5_aliyun_oss-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 590da53d334d8f4a68dc51d7dae0a69f988292aef7ae0931df7077e55a945593
MD5 65e90b43697e199e17d46a647c2fb077
BLAKE2b-256 f4585ddb366893420b72a84b35d56a0bbcf1bdd6a7e16c6bd5c665e59c23995a

See more details on using hashes here.

Supported by

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