📜  uppy tus - Python (1)

📅  最后修改于: 2023-12-03 15:20:54.658000             🧑  作者: Mango

Uppy Tus - Python

Uppy Tus is a Python library that allows you to upload files using the Tus protocol. Tus protocol is a resumable upload protocol that allows you to pause and resume file uploads. Uppy Tus makes it easy for you to integrate Tus protocol into your Python applications.

Installation

You can install Uppy Tus via pip. Just run the following command:

pip install uppy-tus

Alternatively, you can download the source code and install it manually.

Usage

Using Uppy Tus is very simple. First, you need to create an instance of the TusClient class:

from uppy_tus import TusClient

client = TusClient('https://master.tus.io/files/')

Next, you need to create a TusUploader instance:

from uppy_tus import TusUploader

uploader = TusUploader('/path/to/file', client)

Finally, you can upload the file:

uploader.upload()

If the file upload is interrupted, you can resume the upload by running upload() again.

uploader.upload()
Configuration

You can configure the upload by passing in additional parameters to the TusUploader constructor. For example:

uploader = TusUploader('/path/to/file', client, chunk_size=1024)

The available options are:

  • chunk_size: The chunk size in bytes. Defaults to 256KB.
  • metadata: A dictionary of metadata to be sent along with the upload.
  • headers: A dictionary of additional headers to be passed along with the request.
Conclusion

Uppy Tus makes it easy to upload files using Tus protocol in your Python applications. With its simple API, you can quickly integrate file uploads into your application.