tus-py-client 
tus is a protocol based on HTTP for resumable file uploads. Resumable means that an upload can be interrupted at any moment and can be resumed without re-uploading the previous data again. An interruption may happen willingly, if the user wants to pause, or by accident in case of a network issue or server outage.
tus-py-client is a Python client for uploading files using the tus protocol to any remote server supporting it.
Documentation
See documentation here: http://tus-py-client.readthedocs.io/en/latest/
Get started
pip install tuspy
Now you are ready to use the 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', mode=)
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)
If the upload url is known and the client headers are not required, uploaders can also be used standalone.
from tusclient.uploader import Uploader
my_uploader = Uploader('path/to/file.ext',
url='http://tusd.tusdemo.net/files/abcdef123456',
chunk_size=200)
Development
If you want to work on tus-py-client internally, follow these few steps:
-
Setup virtual environment and install dependencies
python -m venv env/ source env/bin/activate pip install -e .[test]
-
Running tests
pytest
-
Releasing a new version (see https://realpython.com/pypi-publish-python-package/)
# Update version in tusclient/__init__.py vim tusclient/__init__.py # Update changelogs vim CHANGELOG.md pytest # Commit and tag git commit -m 'v1.2.3' git tag v1.2.3 # Build and release pip install build twine python -m build twine check dist/* twine upload dist/* # Then: make release on GitHub
License
MIT
Metadata
Release files for tuspy 1.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| tuspy-1.1.0.tar.gz | 16.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| tuspy-1.1.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 32.3 kB
Release files / tuspy-1.1.0.tar.gz
| Download URL | tuspy-1.1.0.tar.gz |
|---|---|
| Size | 16.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
156734eac5c61a046cfecd70f14119f05be92cce198eb5a1a99a664482bedb89
|
|
BLAKE2b-256 checksum How to use checksums |
1121706996ed872ecb6881dec3708cfbc6a3f92026e9e62acc9fcc4bc1019f2d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|
Release files / tuspy-1.1.0-py3-none-any.whl
| Download URL | tuspy-1.1.0-py3-none-any.whl |
|---|---|
| Size | 15.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
7fc5ac8fb25de37c96c90213f83a1ffdede7f48a471cb5a15a2f57846828a79a
|
|
BLAKE2b-256 checksum How to use checksums |
328eb94ec25fcd4384de2a1f5e0403284f005ec743c04bafdb6698c851df5c6d
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/4.0.2 CPython/3.11.7
|