file-retriever

Crates.iofile-retriever
lib.rsfile-retriever
version0.1.1
sourcesrc
created_at2024-04-23 16:57:38.742228
updated_at2024-04-24 05:30:38.903992
descriptionConcurrent download library with progress bar
homepage
repositoryhttps://github.com/bigb4ng/file-retriever
max_upload_size
id1217813
size59,479
(bigb4ng)

documentation

https://docs.rs/file-retriever

README

Retriever

A rust library for downloading files from the web. You can download multiple files asyncronously. The library is built on top of reqwest and tokio. It also utilizes indicatif for progress bars.

Examples

Multiple examples are available in src/lib.rs

Single file download

use reqwest::Client;
use file_retriever::{self, RetrieverBuilder};
use tokio::fs::OpenOptions;

#[tokio::main]
async fn main() -> Result<()> {
    let retriever = RetrieverBuilder::new()
        .show_progress(false)
        .workers(1)
        .build();

    let request = Client::new()
        .get("https://example.com")
        .build()
        .unwrap();

    let output_file = OpenOptions::new()
        .create(true)
        .write(true)
        .truncate(true)
        .open("/tmp/test")
        .await
        .unwrap();

    let _ = retriever.download_file(request, output_file).await;
}

Multiple file download

Example of downloading multiple files can be seen in the multi_download_example.rs

You can run example with:

cargo run --example multi_download_example  -- -i ./examples/in/ -o ./examples/out/

Tests

You can execute tests with:

cargo test --lib

which will create fetch files from mock server to /tmp/ directory

Commit count: 0

cargo fmt