Skip to main content

A django app for Tencent Cloud Object Storage. 腾讯云对象存储(COS)服务 for Django。

Project description

Django TencentCOS Storage

腾讯云对象存储(COS)服务 for Django。

环境要求

Python: >=3.7, <4

Django: >=2.2, <3.3

安装

pip install django-tencentcos-storage

基本使用

在项目的 settings.py 中设置 DEFAULT_FILE_STORAGE

DEFAULT_FILE_STORAGE = "tencentcos_storage.TencentCOSStorage"

此外,还需要设置腾讯云对象存储服务相关的必要信息:

TENCENTCOS_STORAGE = {
    "BUCKET": "存储桶名称",
    "CONFIG": {
        "Region": "地域信息",
        "SecretId": "密钥 SecretId",
        "SecretKey": "密钥 SecretKey",
    }
}

详情可参考 腾讯云对象存储官方文档

设置

示例

TENCENTCOS_STORAGE = {
    # 存储桶名称,必填
    "BUCKET": "存储桶名称",
    # 存储桶文件根路径,选填,默认 '/'
    "ROOT_PATH": "/",
    # 上传文件时最大缓冲区大小(单位 MB),选填,默认 100
    "UPLOAD_MAX_BUFFER_SIZE": 100,
    # 上传文件时分块大小(单位 MB),选填,默认 10
    "UPLOAD_PART_SIZE": 10,
    # 上传并发上传时最大线程数,选填,默认 5
    "UPLOAD_MAX_THREAD": 5,
    # 腾讯云存储 Python SDK 的配置参数,详细说明请参考腾讯云官方文档
    "CONFIG": {
        "Region": "地域信息",
        "SecretId": "密钥 SecretId",
        "SecretKey": "密钥 SecretKey",
    }
}

说明

BUCKET

存储桶名称,必填

ROOT_PATH

文件根路径,选填,默认为 '/'

UPLOAD_MAX_BUFFER_SIZE

上传文件时最大缓冲区大小(单位 MB),选填,默认 100。 其中缓冲区是一个线程安全队列,队列的元素为单个文件分块,队列中所有分块的大小加起来不超过 UPLOAD_MAX_BUFFER_SIZE

UPLOAD_PART_SIZE

上传文件时分块大小(单位 MB),选填,默认 10。 UPLOAD_MAX_BUFFER_SIZEUPLOAD_PART_SIZE 共同决定了缓冲队列的大小,即 QueueSize = UPLOAD_MAX_BUFFER_SIZE / UPLOAD_PART_SIZE

UPLOAD_MAX_THREAD

并发上传的最大线程数,选填,默认 5。 当文件的大小超过 UPLOAD_PART_SIZE 时将使用分块的方式并发上传文件,此配置项设置并发上传的最大线程数。如果文件大小不超过 UPLOAD_PART_SIZE,则不会使用分块的方式上传,此时该配置项不起任何作用。

CONFIG

腾讯云对象存储 Python SDK 的配置参数,其中 RegionSecretIdSecretKey 为必填参数。

关于配置参数的详细说明请参考 腾讯云对象存储 Python SDK 官方文档

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

django-cos-storage-0.5.7.tar.gz (5.8 kB view details)

Uploaded Source

Built Distribution

django_cos_storage-0.5.7-py3-none-any.whl (5.7 kB view details)

Uploaded Python 3

File details

Details for the file django-cos-storage-0.5.7.tar.gz.

File metadata

  • Download URL: django-cos-storage-0.5.7.tar.gz
  • Upload date:
  • Size: 5.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.1 CPython/3.9.7

File hashes

Hashes for django-cos-storage-0.5.7.tar.gz
Algorithm Hash digest
SHA256 e6740da51fe689b3103970fc8e1ad038ca991f5131e42c6c58dbaa9e6d6fd230
MD5 d0da8184ee60948087aa5943e54c156b
BLAKE2b-256 17b36131488acf38e86ec02a68dc37c94a877c40badda52098869d51712d78ca

See more details on using hashes here.

File details

Details for the file django_cos_storage-0.5.7-py3-none-any.whl.

File metadata

File hashes

Hashes for django_cos_storage-0.5.7-py3-none-any.whl
Algorithm Hash digest
SHA256 7e8bacfa84ebd9fc7cedea6171df1f160268d4142c4c09946dd6465be372e47d
MD5 37daf92668c0ac65c94fd86a266ad11b
BLAKE2b-256 f428d1eb85f2ad7be8bc8b73bbc0ff062c81db97eed9e2cc239355e50cc7a562

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