Skip to main content

Python client for Bighead DFS server

Project description

Bighead DFS Python Client

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:断点续传下载。
  • 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.1.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.1-py3-none-any.whl (10.7 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: bighead_dfs_client-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 2230a38b8b943e2432e5a385309dc3b8f2876a3a957917f21f8aab12dffe623e
MD5 51a99be596949faddcc4f8c18641a947
BLAKE2b-256 10574b3b2269a6b226be2b34be41148dfe6deb95bfc9a10e5a9cad21a9457afc

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for bighead_dfs_client-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 2b9f89dc027b93456102e57f289d4792906cf15a1693ac55436cf55e29e5cbb9
MD5 821392921b9eccc9067d78a793250aa0
BLAKE2b-256 648a5d38be266d787a044c07a473fb6671fd7673aebc9d804659bad9a0d45f98

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