Skip to main content

File Upload SDK

上传文件到阿里云 OSS 的 Python SDK

安装

pip install large-file-upload-sdk

使用方法

1. 初始化 SDK

from file_upload_sdk import FileUploadSDK

sdk = FileUploadSDK(
    base_url="https://file-upload-server.ai4s.com.cn/",  # 服务地址
    user_id=12345,            # 你的用户ID(从平台个人中心获取)
    user_name="张三",          # 你的用户名
)
参数 说明 获取方式
base_url 上传服务地址 由管理员提供
user_id 用户ID 登录平台后在个人中心查看
user_name 用户名 你的平台用户名
dataset_id 数据集ID 在平台创建数据集后获取

2. 上传文件夹

result = sdk.upload_folder(
    folder_path="/path/to/your/folder",       # 本地文件夹路径
    dataset_id="419390545334853632",           # 目标数据集ID
)

print(f"总计: {result['total']}, 成功: {result['succeeded']}, 失败: {result['failed_count']}")

3. 上传单个文件

result = sdk.upload_file(
    file_path="/path/to/file.tar.gz",          # 本地文件路径
    dataset_id="419390545334853632",           # 目标数据集ID
)

if result["success"]:
    print(f"上传成功! 路径: {result.get('file_path', '')}")
else:
    print(f"上传失败: {result['error']}")

注意事项

关于压缩包: 平台数据集默认为只读挂载,不支持在数据集目录中原地解压。建议上传时直接上传整个目录(使用 upload_folder),无需打包压缩。如需解压使用,请先将文件复制到个人可写目录后再解压。

常见问题

中断了怎么办? 重新执行同样的命令即可,已上传的文件会自动跳过。

支持多大的文件/目录? 单文件最大 5TB,目录大小无限制。

ossutil 需要手动安装吗? 不需要,首次上传文件夹时会自动下载安装。

Metadata

Release files for large-file-upload-sdk 3.6.2

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

Source distribution (sdist)

Source distribution for large-file-upload-sdk 3.6.2
File Size Uploaded Provenance Actions
large_file_upload_sdk-3.6.2.tar.gz 14.0 kB Without provenance Details for large_file_upload_sdk-3.6.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for large-file-upload-sdk 3.6.2
File Interpreter ABI Platform Actions
large_file_upload_sdk-3.6.2-py3-none-any.whl Python 3 none any Details for large_file_upload_sdk-3.6.2-py3-none-any.whl

Total release size: 26.3 kB

Release files / large_file_upload_sdk-3.6.2.tar.gz

Download URL large_file_upload_sdk-3.6.2.tar.gz
Size 14.0 kB
Tags Source
SHA-256 checksum
How to use checksums
85935024b77641325faa878365408513b0646453289e598ca0bc738770a8ece8
BLAKE2b-256 checksum
How to use checksums
240a7da978d389210874826e3555d88f265626fbb5a279c42b331de9f434004d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Release files / large_file_upload_sdk-3.6.2-py3-none-any.whl

Download URL large_file_upload_sdk-3.6.2-py3-none-any.whl
Size 12.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
e122a94d5954125ab9346ba12ba558c5e5bb6d2600527189ef2b26d5d7aadb24
BLAKE2b-256 checksum
How to use checksums
2e565a69388eee21cbb7ec96711c92cdd900ad8026c33c77c695c52907aa352f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.7

Security for large-file-upload-sdk 3.6.2

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.

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