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.8.1, <4

Django: >=3.2, <6.0

安装

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_tencentcos_storage-0.2.1.tar.gz (5.0 kB view details)

Uploaded Source

Built Distribution

File details

Details for the file django_tencentcos_storage-0.2.1.tar.gz.

File metadata

  • Download URL: django_tencentcos_storage-0.2.1.tar.gz
  • Upload date:
  • Size: 5.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.2 CPython/3.12.2 Linux/5.15.133.1-microsoft-standard-WSL2

File hashes

Hashes for django_tencentcos_storage-0.2.1.tar.gz
Algorithm Hash digest
SHA256 0c2a173589803a2fe242a228cea4258647b8d883755630e696ccd2c46c61eab8
MD5 f0c4f940ae94b4da1e1c05154cc7607a
BLAKE2b-256 b90f8e54008a9ca761b5733d91e0f6d6e62e52d7f78d56f9d3a005ea51df3a6a

See more details on using hashes here.

File details

Details for the file django_tencentcos_storage-0.2.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_tencentcos_storage-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 56bef4c22bbf370cffdaeee1d43b6431e501403e972d599f6af63c4d0b2f96d4
MD5 f41bd646d04159376b209fb75f13713a
BLAKE2b-256 4010e55fae1fa156ee2eaef149a537947ac752655d3c2a8a7761a12b9c38f56c

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