Skip to main content

Tencent Cloud Django COS Storage

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

环境要求

Python: >=3.7, <4

Django: >=2.2, <3.3

安装

pip install tencentcloud-django-cos-storage

基本使用

在项目的 settings.py 中设置 DEFAULT_FILE_STORAGE:

DEFAULT_FILE_STORAGE = "django_cos_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中字段的大小写请与python-sdk中CosConfig的构造参数保持一致
    "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_SIZE 和 UPLOAD_PART_SIZE 共同决定了缓冲队列的大小,即 QueueSize = UPLOAD_MAX_BUFFER_SIZE / UPLOAD_PART_SIZE。

UPLOAD_MAX_THREAD

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

CONFIG

注意:CONFIG中字段的大小写请与python-sdk中CosConfig的构造参数保持一致

腾讯云对象存储 Python SDK 的配置参数,其中 Region、SecretId、SecretKey 为必填参数。 关于配置参数的详细说明请参考 腾讯云对象存储 Python SDK 官方文档

Metadata

Release files for tencentcloud-django-cos-storage 0.0.1

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

Source distribution (sdist)

Source distribution for tencentcloud-django-cos-storage 0.0.1
File Size Uploaded Provenance Actions
tencentcloud_django_cos_storage-0.0.1.tar.gz 5.2 kB Without provenance Details for tencentcloud_django_cos_storage-0.0.1.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for tencentcloud-django-cos-storage 0.0.1
File Interpreter ABI Platform Actions
tencentcloud_django_cos_storage-0.0.1-py3-none-any.whl Python 3 none any Details for tencentcloud_django_cos_storage-0.0.1-py3-none-any.whl

Total release size: 11.2 kB

Release files / tencentcloud_django_cos_storage-0.0.1.tar.gz

Download URL tencentcloud_django_cos_storage-0.0.1.tar.gz
Size 5.2 kB
Tags Source
SHA-256 checksum
How to use checksums
bf67d2acff05ad7f6682349f50c41a4d1d2f5f4147c73efe3c1a04b10e41e6e7
BLAKE2b-256 checksum
How to use checksums
fed21ecd97f3ce7b3f55b8fba34fba501ac906cc771e3754564c069673e8766b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Release files / tencentcloud_django_cos_storage-0.0.1-py3-none-any.whl

Download URL tencentcloud_django_cos_storage-0.0.1-py3-none-any.whl
Size 6.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
bd9ebbf2f3217ffb77e849066b43811a96f1c34319ff41d6da9de76bcc4dd066
BLAKE2b-256 checksum
How to use checksums
c19f5eb111b6782091b657fc8276fd42fce27c8f1481b4b7478e188dc54da0b8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.2 CPython/3.9.6

Security for tencentcloud-django-cos-storage 0.0.1

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

0.0.1 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