Skip to main content

tus 可恢复上传协议的 Python 客户端 -> http://tus.io

项目描述

tus-py-客户端构建状态

tus是一种基于 HTTP 的可恢复文件上传协议。可恢复意味着上传可以随时中断,无需重新上传之前的数据即可恢复。如果用户想要暂停,或者在网络问题或服务器中断的情况下意外发生,中断可能会发生。

tus-py-client是一个 Python 客户端,用于使用tus协议将文件上传到任何支持它的远程服务器。

文档

请参阅此处的文档:http: //tus-py-client.readthedocs.io/en/latest/

开始使用

pip install tuspy

现在您已准备好使用该 api。

from tusclient import client

# Set Authorization headers if it is required
# by the tus server.
my_client = client.TusClient('http://tusd.tusdemo.net/files/',
                              headers={'Authorization': 'Basic xxyyZZAAbbCC='})

# Set more headers.
my_client.set_headers({'HEADER_NAME': 'HEADER_VALUE'})

uploader = my_client.uploader('path/to/file.ext', chunk_size=200)

# A file stream may also be passed in place of a file path.
fs = open('path/to/file.ext')
uploader = my_client.uploader(file_stream=fs, chunk_size=200)

# Upload a chunk i.e 200 bytes.
uploader.upload_chunk()

# Uploads the entire file.
# This uploads chunk by chunk.
uploader.upload()

# you could increase the chunk size to reduce the
# number of upload_chunk cycles.
uploader.chunk_size = 800
uploader.upload()

# Continue uploading chunks till total chunks uploaded reaches 1000 bytes.
uploader.upload(stop_at=1000)

如果上传 url 已知且不需要客户端标头,则上传器也可以单独使用。

from tusclient.uploader import Uploader

my_uploader = Uploader('path/to/file.ext',
                       url='http://tusd.tusdemo.net/files/abcdef123456',
                       chunk_size=200)

执照

麻省理工学院

下载文件

下载适用于您平台的文件。如果您不确定要选择哪个,请了解有关安装包的更多信息。

源分布

tuspy-1.0.0.tar.gz (11.8 kB 查看哈希

已上传 source