Skip to main content

Large File Upload SDK - Support chunked upload, resumable transfer, and Token authentication

Project description

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 需要手动安装吗? 不需要,首次上传文件夹时会自动下载安装。

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

large_file_upload_sdk-3.6.2.tar.gz (14.0 kB view details)

Uploaded Source

Built Distribution

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

large_file_upload_sdk-3.6.2-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file large_file_upload_sdk-3.6.2.tar.gz.

File metadata

  • Download URL: large_file_upload_sdk-3.6.2.tar.gz
  • Upload date:
  • Size: 14.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.11.7

File hashes

Hashes for large_file_upload_sdk-3.6.2.tar.gz
Algorithm Hash digest
SHA256 85935024b77641325faa878365408513b0646453289e598ca0bc738770a8ece8
MD5 993731515da471d1ba63de0db6b465a4
BLAKE2b-256 240a7da978d389210874826e3555d88f265626fbb5a279c42b331de9f434004d

See more details on using hashes here.

File details

Details for the file large_file_upload_sdk-3.6.2-py3-none-any.whl.

File metadata

File hashes

Hashes for large_file_upload_sdk-3.6.2-py3-none-any.whl
Algorithm Hash digest
SHA256 e122a94d5954125ab9346ba12ba558c5e5bb6d2600527189ef2b26d5d7aadb24
MD5 d4c57af0096785ec87cfb7a8e5913e24
BLAKE2b-256 2e565a69388eee21cbb7ec96711c92cdd900ad8026c33c77c695c52907aa352f

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