tus_async_client

Crates.iotus_async_client
lib.rstus_async_client
version0.2.1
sourcesrc
created_at2021-07-30 12:57:29.512385
updated_at2022-06-24 16:26:29.818722
descriptionA Rust native async client library to interact with *tus* enabled endpoints.
homepage
repositoryhttps://github.com/rambus-dumbledore/tus_async_client
max_upload_size
id429278
size37,713
Ilya Volchenkov (zryambus)

documentation

README

tus_async_client

Fork of tus_client

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

Usage

Create an instance of the tus_async_client::Client struct.

use tus_async_client::{Client, HttpHandler};
use reqwest;
use std::sync::Arc;

let client = Client::new(Arc::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").await?
    .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").await?
    .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: 35

cargo fmt