13 releases (1 stable)
Uses new Rust 2024
| new 1.0.0 | Jan 28, 2026 |
|---|---|
| 0.4.3 | Jan 9, 2026 |
| 0.4.2 | Jul 24, 2025 |
| 0.4.1 | Feb 27, 2025 |
| 0.2.3 | Mar 10, 2021 |
#260 in Filesystem
45KB
718 lines
Siwi Download
Download file
Siwi Download is a downloader built on tokio and reqwest with breakpoint continuation support.
Features
- 🚀 Async download - Built on tokio for high performance
- 📊 Progress bar - Visual download progress
- 🔄 Resume support - Breakpoint continuation for interrupted downloads
- 🌐 Proxy support - HTTP/HTTPS proxy support
- 📁 Custom paths - Specify output directory and filename
- 📄 JSON output - Machine-readable report output
- 🔧 Library API - Use as a Rust library in your project
Install
cargo install siwi-download
CLI Usage
siwi-download <URL> [OPTIONS]
Options
| Option | Short | Description | Default |
|---|---|---|---|
<url> |
positional | URL to download (first argument) | Required |
--url |
-u |
URL to download (alternative) | - |
--output |
-o |
Output directory | Current directory |
--filename |
-f |
Custom filename | Auto-extracted from URL |
--progress |
-P |
Show progress bar | true |
--proxy |
-p |
HTTP proxy URL | None |
--verbose |
-v |
Verbose logging | false |
--json |
-j |
Output report in JSON format | false |
--help |
-h |
Show help | - |
--version |
-V |
Show version | - |
Examples
Basic download (simplified):
siwi-download https://nodejs.org/dist/v22.11.0/node-v22.11.0.pkg
Basic download (with flag):
siwi-download -u https://nodejs.org/dist/v22.11.0/node-v22.11.0.pkg
Download to specific directory with progress:
siwi-download https://example.com/file.zip -o /tmp/downloads -P
Download with custom filename:
siwi-download https://example.com/download -f my-custom-name.zip
Download through proxy:
siwi-download https://large-file.iso -p http://127.0.0.1:7890 -P
Verbose mode for debugging:
siwi-download https://example.com/file.zip -v
JSON output for scripting:
siwi-download https://example.com/file.zip -j
Output Example (JSON format):
{
"url": "https://example.com/file.zip",
"file_name": "file.zip",
"origin_file_name": "file.zip",
"storage_path": "/downloads",
"file_path": "/downloads/file.zip",
"file_size": 1048576,
"download_status": "Complete",
"head_status": 200,
"resp_status": 206,
"time_used": 5
}
Library Usage
cargo run --example download
use reqwest::header::{HeaderMap, HeaderValue, USER_AGENT};
use siwi_download::{
download::{Download, DownloadOptions},
error::AnyResult,
};
use tracing::Level;
use tracing_subscriber::FmtSubscriber;
#[tokio::main]
async fn main() -> AnyResult<()> {
let subscriber = FmtSubscriber::builder()
.with_max_level(Level::INFO)
.finish();
tracing::subscriber::set_global_default(subscriber).expect("setting default subscriber failed");
let url = "https://nodejs.org/dist/v22.11.0/node-v22.11.0.pkg";
let mut storage_path = std::env::current_dir()?;
storage_path.push("storage");
let storage_path = storage_path.to_str().unwrap();
let mut options = DownloadOptions::default();
let mut headers = HeaderMap::new();
headers.insert(USER_AGENT, HeaderValue::from_str("Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36")?);
options
.set_headers(headers)
.set_file_name("node-v22.11.0.pkg")
.set_show_progress(true);
let download = Download::new(storage_path);
download.auto_create_storage_path().await?;
let report = download.download(url, options).await?;
println!("report {:#?}", report);
Ok(())
}
See examples/download.rs for complete library examples.
Dependencies
~16–35MB
~395K SLoC