Skip to content
forked from cenkalti/tus.py

tus (resumable file upload protocol) client in python

License

Notifications You must be signed in to change notification settings

simon-says/tus.py

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

tus.py

tus (resumable file upload protocol) client compatible with python 3

Requirements

You must be running Python3 to use tus

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.

About

tus (resumable file upload protocol) client in python

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Python 100.0%