All Projects → cenkalti → tus.py

cenkalti / tus.py

Licence: MIT license
tus (resumable file upload protocol) client in python

Programming Languages

python
139335 projects - #7 most used programming language

tus.py

tus (resumable file upload protocol) client in python

Install

pip install -U tus.py

Usage (command line)

This command will upload a single file to the server:

tus-upload \
    example.bin \
    https://upload.example.com/files/ \
    --header authorization 'token foo' \
    --chunk-size 256000

After upload request is accepted on server, upload location is printed to stdout.

If upload fails at any point, program will exit with a non-zero code.

You can continue uploading with following command:

tus-resume \
    example.bin \
    https://upload.example.com/files/393ebd3506d3a42994c1563c1f8c5684 \
    --header authorization 'token foo' \
    --chunk-size 256000

Usage (Python)

The following example uploads a file in single call.

import tus

FILE_PATH = 'example.bin'
TUS_ENDPOINT = 'https://upload.example.com/files/'
HEADERS = {'Authorization': 'token foo'}
CHUNK_SIZE = 256000

with open(FILE_PATH, 'rb') as f:
    tus.upload(
    	f,
        TUS_ENDPOINT,
        headers=headers,
        chunk_size=CHUNK_SIZE)

If you want resume feature use tus.create() and tus.resume() functions.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].