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
my_client = client.TusClient('http://tusd.tusdemo.net/files/',
headers={'Authorization': 'Basic xxyyZZAAbbCC='})
my_client.set_headers({'HEADER_NAME': 'HEADER_VALUE'})
uploader = my_client.uploader('path/to/file.ext', chunk_size=200)
fs = open('path/to/file.ext', mode=)
uploader = my_client.uploader(file_stream=fs, chunk_size=200)
uploader.upload_chunk()
uploader.upload()
uploader.chunk_size = 800
uploader.upload()
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/)
vim tusclient/__init__.py
vim CHANGELOG.md
pytest
git commit -m 'v1.2.3'
git tag v1.2.3
pip install build twine
python -m build
twine check dist/*
twine upload dist/*
License
MIT