Crates.io | file-retriever |
lib.rs | file-retriever |
version | 0.1.1 |
source | src |
created_at | 2024-04-23 16:57:38.742228 |
updated_at | 2024-04-24 05:30:38.903992 |
description | Concurrent download library with progress bar |
homepage | |
repository | https://github.com/bigb4ng/file-retriever |
max_upload_size | |
id | 1217813 |
size | 59,479 |
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.
Multiple examples are available in src/lib.rs
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;
}
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/
You can execute tests with:
cargo test --lib
which will create fetch files from mock server to /tmp/
directory