Skip to main content

PyUploadX Python SDK

pyuploadx 是 PyUploadX 文件/目录上传服务的 Python 客户端 SDK,支持小文件 Proxy 上传、 大文件 Multipart 分片 + 断点续传、目录上传(Manifest + .uploadignore)与生命周期策略。 协议与状态机见 docs/docs_product-design.md §17/§12/§13。

安装

pip install pyuploadx          # Python ≥ 3.11,第三方依赖仅 httpx

快速开始

from datetime import timedelta
from pyuploadx import UploadClient, FileLifecycle

client = UploadClient(
    base_url="http://localhost:8000",
    api_key="dev-key",
    state_dir="~/.pyuploadx/uploads",
)

result = client.upload_file(
    "./README.md",
    bucket="app-default",
    lifecycle=FileLifecycle.ttl(timedelta(days=30)),
)

job = client.upload_directory(
    "./album-assets",
    bucket="app-default",
    destination_prefix="artists/10001",
    conflict_policy="reject",
)

获取结果与状态

上传接口同步返回结果对象(FileInfo / DirectoryJobInfo),后续可通过查询接口随时获取服务端最新状态。

# 上传结果:文件元数据与状态
info = client.upload_file("./README.md", bucket="app-default")
print(info.id, info.status, info.size_bytes, info.etag)

# 大文件 Multipart 会话:查询分片上传状态(status: initiated/uploading/completed)
session = client.create_upload(bucket="app-default", object_key="model.bin", total_size=1024, part_size=256)
probe = client.get_upload(session.id)
print(probe.status, probe.completed_file_id)

# 目录上传:任务统计与状态(completed/failed_files/uploaded_bytes)
job = client.upload_directory("./album-assets", bucket="app-default")
print(job.status, job.uploaded_files, job.failed_files, job.uploaded_bytes)

# 事后查询:文件最新状态、生命周期与下载
info = client.get_file(info.id)                 # FileInfo:status/expires_at/legal_hold/completed_at
lifecycle = client.get_lifecycle(info.id)       # 生效生命周期
client.update_lifecycle(info.id, {"mode": "ttl", "ttl_seconds": 3600})
client.download(info.id, "/tmp/README.md")      # 下载原文件
client.delete(info.id)                          # 删除(幂等)

发版

SDK 与服务端分开发布:SDK 包 pyuploadx 在本目录构建 (bash scripts/publish-pypi.sh),服务端包 pyuploadx-server 在仓库根构建 (bash scripts/publish-pypi-server.sh),详见 docs/docs_product-design.md §37。

Metadata

Release files for pyuploadx 0.3.0

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

Source distribution (sdist)

Source distribution for pyuploadx 0.3.0
File Size Uploaded
pyuploadx-0.3.0.tar.gz 15.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for pyuploadx 0.3.0
File Interpreter ABI Platform
pyuploadx-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 32.5 kB

Release files / pyuploadx-0.3.0.tar.gz

Download URL pyuploadx-0.3.0.tar.gz
Size 15.0 kB
Tags Source
SHA-256 checksum
How to use checksums
925c529ca58277d9fca412015dcd7b64fe2a599b86c7c0908fa885d5447525e6
BLAKE2b-256 checksum
How to use checksums
0e6bd059e0b7fee8ee050f366847c9fb9e9bc9ca1846ddb0f946d3888eb4bfe2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release files / pyuploadx-0.3.0-py3-none-any.whl

Download URL pyuploadx-0.3.0-py3-none-any.whl
Size 17.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
3e974749f4846e4abf8fa4762cadfcf3eda63d3410c7794e9fcc316f736ffc9a
BLAKE2b-256 checksum
How to use checksums
50ad707a4a91734ab0ae4ea2752bae70dbf06ac3cfa1111d5dc5f3c91fc11b2c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.3

Release history Release notifications | RSS feed

0.10.1

2 release files

0.10.0

2 release files

0.9.0

2 release files

0.8.0

2 release files

0.7.0

2 release files

0.6.0

2 release files

0.5.0

2 release files

0.4.0

2 release files

This release

0.3.0 This release

2 release files

0.2.0

2 release files

0.1.0

2 release files

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