tus_client_extra

Crates.iotus_client_extra
lib.rstus_client_extra
version0.1.1
sourcesrc
created_at2022-07-23 05:51:25.907596
updated_at2022-07-23 05:51:25.907596
descriptionA Rust native client library to interact with *tus* enabled endpoints.
homepage
repositoryhttps://github.com/Bysness/tus_client_extra
max_upload_size
id631287
size48,593
Anuraag Vaidya (anuraagvaidya)

documentation

README

tus_client_extra

A Rust native client library to interact with tus enabled endpoints.

reqwest implementation

tus_client_extra requires a "handler" which implements the HttpHandler trait. To include a default implementation of this trait for reqwest, specify the reqwest feature when including tus_client_extra as a dependency.

# Other parts of Cargo.toml omitted for brevity
[dependencies]
tus_client_extra = {version = "x.x.x", features = ["reqwest"]}

Usage

Create an instance of the tus_client_extra::Client struct.

use tus_client_extra::Client;
use reqwest;

// Assumes "reqwest" feature is enabled (see above)
let client = Client::new(reqwest::Client::new());

You'll need an upload URL to be able to upload a files. This may be provided to you (through a separate API, for example), or you might need to create the file through the tus protocol. If an upload URL is provided for you, you can skip this step.

let upload_url = client
    .create("https://my.tus.server/files/", "/path/to/file")
    .expect("Failed to create file on server");

Next, you can start uploading the file by calling upload. The file will be uploaded in 5 MiB chunks by default. To customize the chunk size, use upload_with_chunk_size instead of upload.

client
    .upload(&upload_url, "/path/to/file")
    .expect("Failed to upload file to server");

upload (and upload_with_chunk_size) will automatically resume the upload from where it left off, if the upload transfer is interrupted.

Commit count: 32

cargo fmt