Skip to main content

Python client for Bighead DFS server

Project description

Bighead DFS Python Client

PyPI - Version Python Versions

Python 版本的 Bighead DFS 客户端

功能概览

  • upload_resource_by_path / upload_resource_by_bytes:小文件上传,包含 MD5 指纹计算与秒传判断。
  • parts_upload_resource:分片上传,支持断点续传和进度回调。
  • resource_exist:检测资源是否已存在。
  • generate_browse_url / generate_thumbnail_browse_url:生成带签名的访问链接与缩略图链接。
  • download_file:带 Range 头的断点续传下载。
  • video_duration:获取视频资源时长信息。
  • offline_download:提交离线下载任务。

安装

pip install bighead-dfs-client

快速上手

from bighead_dfs_client import BigheadDfsClient, BigheadDfsConfig

config = BigheadDfsConfig(
    url="https://your-dfs-host:8221",
    app_id="your-app-id",
    app_secret="your-app-secret"
)

client = BigheadDfsClient(config)
# 若需启用证书校验,可:
# client.session.verify = True

上传文件

# 通过文件路径上传
fingerprint = client.upload_resource_by_path("Daily", r"C:\tmp\demo.jpg", "演示文件")
print("上传完成:", fingerprint)

# 若已获取字节内容
with open(r"C:\tmp\demo.jpg", "rb") as f:
    fingerprint = client.upload_resource_by_bytes("Daily", f.read(), "demo.jpg")

分片上传

def show_progress(progress: int):
    print(f"progress={progress}%")

fingerprint = client.parts_upload_resource(
    "Daily",
    r"C:\tmp\large_video.mp4",
    description="大文件示例",
    progress_action=show_progress
)

基础能力

if client.resource_exist("Daily", fingerprint):
    print("资源已存在,可直接使用")

print(client.generate_browse_url("Daily", fingerprint))
print(client.generate_thumbnail_browse_url("Daily", fingerprint, 300, 200))

def downloaded(bucket, file_id):
    print("下载完成:", bucket, file_id)

client.download_file(r"C:\tmp\downloaded.mp4", "Daily", fingerprint, downloaded)

视频与离线任务

duration_info = client.video_duration("Daily", fingerprint)
print("视频时长信息:", duration_info)

client.offline_download(
    target_url="https://example.com/source/file.zip",
    call_back_url="https://your-service/callback",
    payload='{"custom":"data"}'
)

根据实际环境修改 bucket_nameurlapp_idapp_secret 以及本地文件路径即可。

贡献与许可证

  • Python 3.8+
  • 依赖:requests
  • 许可证:MIT

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

bighead_dfs_client-0.1.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

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

bighead_dfs_client-0.1.0-py3-none-any.whl (10.8 kB view details)

Uploaded Python 3

File details

Details for the file bighead_dfs_client-0.1.0.tar.gz.

File metadata

  • Download URL: bighead_dfs_client-0.1.0.tar.gz
  • Upload date:
  • Size: 10.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.0

File hashes

Hashes for bighead_dfs_client-0.1.0.tar.gz
Algorithm Hash digest
SHA256 06fb03365845d922d75e6662ec4b43541ba80a1bf956dbad4e8865723df1896c
MD5 06c0161d0560d32275080420367119eb
BLAKE2b-256 ac6ec9e33b2a4ec39b2eb8a62def708d037dfe9ad2d25b96b7d56724232c06be

See more details on using hashes here.

File details

Details for the file bighead_dfs_client-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for bighead_dfs_client-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 871442d09e98dc9bf73eb2410ab66d0a12e18ad5e961a9a51436e1c71df4d0d5
MD5 fb4af44fc740bfb5e6c72ba246a40daf
BLAKE2b-256 22a7b51220b009bfe6450458e9cf81df3cfd0da5de81b34ae1eeb6e1370c5b21

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