django5-aliyun-oss


Namedjango5-aliyun-oss JSON
Version 1.1.2 PyPI version JSON
download
home_pagehttps://github.com/mircool/django-aliyun-oss
SummaryDjango5 storage backend for Aliyun OSS
upload_time2024-10-29 03:02:00
maintainerNone
docs_urlNone
authorMircool
requires_python>=3.8
licenseNone
keywords django aliyun oss storage file upload
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Django 5 阿里云 OSS 存储

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

## 安装

```bash
pip install django5-aliyun-oss
```

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

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


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

```python
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',
    }
}
```

## 使用

```python
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 许可证

## 贡献

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

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/mircool/django-aliyun-oss",
    "name": "django5-aliyun-oss",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": "django, aliyun, oss, storage, file upload",
    "author": "Mircool",
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/57/19/20257505aa52353ec5c838118d7ec3567fb24a57c3843bbcb4ea2ec68027/django5-aliyun-oss-1.1.2.tar.gz",
    "platform": null,
    "description": "# Django 5 \u963f\u91cc\u4e91 OSS \u5b58\u50a8\r\n\r\n\u7528\u4e8e\u963f\u91cc\u4e91 OSS\uff08\u5bf9\u8c61\u5b58\u50a8\u670d\u52a1\uff09\u7684 Django \u5b58\u50a8\u540e\u7aef\u3002\r\n\r\n## \u5b89\u88c5\r\n\r\n```bash\r\npip install django5-aliyun-oss\r\n```\r\n\r\n## \u914d\u7f6e\r\n\u5728\u60a8\u7684 Django settings.py INSTALLED_APPS \u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u8bbe\u7f6e\uff1a\r\n\r\n```python\r\nINSTALLED_APPS = [\r\n    ...\r\n    'django5_aliyun_oss',\r\n    ...\r\n]\r\n```\r\n\r\n\r\n\u5728\u60a8\u7684 Django settings.py \u4e2d\u6dfb\u52a0\u4ee5\u4e0b\u8bbe\u7f6e\uff1a\r\n\r\n```python\r\nALIYUN_OSS = {\r\n    'ACCESS_KEY_ID': '\u60a8\u7684\u8bbf\u95ee\u5bc6\u94a5ID',\r\n    'ACCESS_KEY_SECRET': '\u60a8\u7684\u8bbf\u95ee\u5bc6\u94a5\u5bc6\u7801',\r\n    'ENDPOINT': '\u60a8\u7684\u7ec8\u7aef\u8282\u70b9',\r\n    'BUCKET_NAME': '\u60a8\u7684\u5b58\u50a8\u6876\u540d\u79f0',\r\n    'URL_EXPIRE_SECONDS': 3600,  # \u53ef\u9009\uff0c\u9ed8\u8ba4\u4e3a3600\r\n}\r\n\r\n# \u8bbe\u7f6e\u4e3a\u9ed8\u8ba4\u5b58\u50a8\u5668\r\nSTORAGES = {\r\n    'default': {\r\n        'BACKEND': 'django5_aliyun_oss.storage.AliyunOSSStorage',\r\n    },\r\n    'staticfiles': {\r\n        'BACKEND': 'django.contrib.staticfiles.storage.StaticFilesStorage',\r\n    }\r\n}\r\n```\r\n\r\n## \u4f7f\u7528\r\n\r\n```python\r\nfrom django.db import models\r\n\r\nclass YourModel(models.Model):\r\n    file = models.FileField(upload_to='uploads/')\r\n    image = models.ImageField(upload_to='images/')\r\n```\r\n\r\n## \u7279\u6027\r\n\r\n- \u517c\u5bb9 Django 5.0+\r\n- \u652f\u6301\u6240\u6709\u57fa\u672c\u6587\u4ef6\u64cd\u4f5c\r\n- \u5904\u7406\u6587\u4ef6\u5220\u9664\r\n- \u8fd4\u56de\u7684URL\u662f\u5e26\u7b7e\u540d\u7684URL\r\n- \u53ef\u914d\u7f6e\u7684\u4e0a\u4f20\u8def\u5f84\r\n- \u652f\u6301\u9759\u6001\u6587\u4ef6\u5b58\u50a8\r\n\r\n## \u8bb8\u53ef\u8bc1\r\n\r\nMIT \u8bb8\u53ef\u8bc1\r\n\r\n## \u8d21\u732e\r\n\r\n\u6b22\u8fce\u8d21\u732e\uff01\u8bf7\u968f\u65f6\u63d0\u4ea4\u62c9\u53d6\u8bf7\u6c42\u3002\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Django5 storage backend for Aliyun OSS",
    "version": "1.1.2",
    "project_urls": {
        "Bug Tracker": "https://github.com/mircool/django-aliyun-oss/issues",
        "Homepage": "https://github.com/mircool/django-aliyun-oss"
    },
    "split_keywords": [
        "django",
        " aliyun",
        " oss",
        " storage",
        " file upload"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5c9b40a16205d32a53ec74e6212475afae9d042bdbb798f959a5542d77e7575b",
                "md5": "a226eb27e4f940389f37890d96eb2c69",
                "sha256": "126a0c297bccca5a782185669c473627d363640bd4e41df7e0cd48c8146359fe"
            },
            "downloads": -1,
            "filename": "django5_aliyun_oss-1.1.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "a226eb27e4f940389f37890d96eb2c69",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 5755,
            "upload_time": "2024-10-29T03:01:57",
            "upload_time_iso_8601": "2024-10-29T03:01:57.887420Z",
            "url": "https://files.pythonhosted.org/packages/5c/9b/40a16205d32a53ec74e6212475afae9d042bdbb798f959a5542d77e7575b/django5_aliyun_oss-1.1.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "571920257505aa52353ec5c838118d7ec3567fb24a57c3843bbcb4ea2ec68027",
                "md5": "1bd957b325b11955141725e3227f8b31",
                "sha256": "df33bdf491c2d971bcb5804cdb532e2c44b9b6da8af1ecabb4d82efbd4bcf82e"
            },
            "downloads": -1,
            "filename": "django5-aliyun-oss-1.1.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1bd957b325b11955141725e3227f8b31",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 5138,
            "upload_time": "2024-10-29T03:02:00",
            "upload_time_iso_8601": "2024-10-29T03:02:00.583357Z",
            "url": "https://files.pythonhosted.org/packages/57/19/20257505aa52353ec5c838118d7ec3567fb24a57c3843bbcb4ea2ec68027/django5-aliyun-oss-1.1.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-10-29 03:02:00",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "mircool",
    "github_project": "django-aliyun-oss",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "requirements": [],
    "lcname": "django5-aliyun-oss"
}
        
Elapsed time: 0.91217s