Skip to main content

Python SDK for material upload

Project description

Gravity Material Upload

Python SDK,用于批量上传图片和视频素材。

功能特性

  • 🔍 智能文件扫描 — 支持扫描目录、指定文件、通配符匹配,自动过滤有效的图片/视频文件
  • 📤 分片上传 — 基于 TOS 对象存储的分片上传,支持大文件传输
  • 📊 进度显示 — 双层进度条实时展示文件级和字节级上传进度
  • 🖼️ 自动解析 — 自动获取图片/视频的宽高、时长、MD5 等元信息

支持的文件格式

类型 后缀
图片 .png .jpg .jpeg .gif
视频 .mp4 .3gp .avi .mov

快速开始

1. 安装依赖

python -m pip install -e .

该命令会以开发模式安装本包及所有依赖(Pillow、tos、requests、opencv-python、tqdm)。

2. 使用示例

from gravity_material_upload import MaterialClient

# 1. 创建客户端
client = MaterialClient(
    app_key="your_app_key",
)

# 2. 一键上传素材(扫描 + 上传)
client.upload_material(
    source_paths=["./video1.mp4", "./image1.png"], # 目标路径,支持目录、文件列表、通配符
    recursive=True,                           # 是否递归搜索子目录,在source_paths传入目录时生效
    allowed_extensions=[".png", ".mp4"], # 可选:自定义文件后缀白名单
    max_workers=5,                            # 可选:最大并发上传数
    upload_config={                           # 必填:自定义上传配置参数
        "album_id": 123,
        "remark": "your_remark",
    },
)

upload_material() 参数说明

参数 类型 默认值 说明
source_paths str | List[str] "." 目标路径,支持文件、目录、通配符,可使用相对路径
recursive bool True 是否递归搜索子目录
allowed_extensions Tuple[str, ...] None 自定义文件后缀白名单,仅保留在默认支持列表中的后缀
max_workers int 5 最大并发上传线程数
upload_config Object 必填 自定义上传配置参数,合并到接口根层级

环境要求

  • Python >= 3.7

许可证

Apache-2.0

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

gravity_material_upload-1.0.1.tar.gz (18.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

gravity_material_upload-1.0.1-py3-none-any.whl (20.0 kB view details)

Uploaded Python 3

File details

Details for the file gravity_material_upload-1.0.1.tar.gz.

File metadata

  • Download URL: gravity_material_upload-1.0.1.tar.gz
  • Upload date:
  • Size: 18.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.14.3

File hashes

Hashes for gravity_material_upload-1.0.1.tar.gz
Algorithm Hash digest
SHA256 1aa3a11752d2ef3a635a7fa15c995e06bcd92eb6e5fc34f03db45f6453cb554e
MD5 3639f884d03ddb968ad8136585809778
BLAKE2b-256 33b43fed0dcb3aee2f065ab147c8d7b372320c3dd29c881e25d23dd34519d11c

See more details on using hashes here.

File details

Details for the file gravity_material_upload-1.0.1-py3-none-any.whl.

File metadata

File hashes

Hashes for gravity_material_upload-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 3b5adbfcae5f7ce5298be87738f666effb0455d8164bc0b23ea5695b575830b4
MD5 a435e9da2fb9b77de13ef84a477a73f7
BLAKE2b-256 bdc4af5b5ad2772b979c6108e88ed88df9d36f6f8a84472ca07e04b8f02f2c06

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page