Skip to main content

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+
  • 支持所有基本文件操作
  • 处理文件删除
  • 返回的URL是带签名的URL
  • 可配置的上传路径
  • 支持静态文件存储

许可证

MIT 许可证

贡献

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

Metadata

Release files for django5-aliyun-oss 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 django5-aliyun-oss 1.1.2
File Size Uploaded
django5-aliyun-oss-1.1.2.tar.gz 5.1 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django5-aliyun-oss 1.1.2
File Interpreter ABI Platform
django5_aliyun_oss-1.1.2-py3-none-any.whl Python 3 none any Details

Total release size: 10.9 kB

Release files / django5-aliyun-oss-1.1.2.tar.gz

Download URL django5-aliyun-oss-1.1.2.tar.gz
Size 5.1 kB
Tags Source
SHA-256 checksum
How to use checksums
df33bdf491c2d971bcb5804cdb532e2c44b9b6da8af1ecabb4d82efbd4bcf82e
BLAKE2b-256 checksum
How to use checksums
571920257505aa52353ec5c838118d7ec3567fb24a57c3843bbcb4ea2ec68027
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

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

Download URL django5_aliyun_oss-1.1.2-py3-none-any.whl
Size 5.8 kB
Tags Python 3
SHA-256 checksum
How to use checksums
126a0c297bccca5a782185669c473627d363640bd4e41df7e0cd48c8146359fe
BLAKE2b-256 checksum
How to use checksums
5c9b40a16205d32a53ec74e6212475afae9d042bdbb798f959a5542d77e7575b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.1.1 CPython/3.12.0

Release history Release notifications | RSS feed

This release

1.1.2 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.9

2 release files

1.0.8

2 release files

1.0.7

2 release files

1.0.6

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

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