Skip to main content

A Python client for the tus resumable upload protocol -> http://tus.io

Project description

# tus-py-client [![Build Status](https://travis-ci.org/tus/tus-py-client.svg?branch=master)](https://travis-ci.org/tus/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

```bash
pip install tuspy
```

Now you are ready to use the api.

``` python
from tusclient import client

# Set Authorization headers if it is required
# by the tus server.
my_client = client.TusClient('http://master.tus.io/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)
```

If the upload url is known and the client headers are not required, uploaders can also be used standalone.

``` python
from tusclient.uploader import Uploader

my_uploader = Uploader('path/to/file.ext',
url='http://master.tus.io/files/abcdef123456',
chunk_size=200)
```

## License

MIT

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tuspy-0.2.1.tar.gz (9.7 kB view details)

Uploaded Source

File details

Details for the file tuspy-0.2.1.tar.gz.

File metadata

  • Download URL: tuspy-0.2.1.tar.gz
  • Upload date:
  • Size: 9.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No

File hashes

Hashes for tuspy-0.2.1.tar.gz
Algorithm Hash digest
SHA256 fd51ceeddaf35db176d27bce5e1958f93edcf12fbed0473f3bf8132e8e19d906
MD5 4d86596937afb2515b94773fc0540719
BLAKE2b-256 ce23f8cdb6ec7a3c43b8913843279bc4a61736578a1d0f950c3dd6a94f13fc0e

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page