NetZip is a Rust library and CLI tool that allows you to work with remote ZIP files over HTTP without downloading the entire archive. It uses HTTP range requests to efficiently fetch only the parts of the ZIP file that are needed.
- 🚀 Network Efficient - Download only the parts of the ZIP file you need
- 📋 List Files - List the contents of a remote ZIP file
- 📦 Extract Files - Download specific files from a remote ZIP
- 🧩 Library & CLI - Use as a library in your Rust projects or as a command-line tool
cargo install netzip_cligit clone https://github.com/sysrqmagician/netzip.git
cd netzip
cargo build --releaseThe binary will be available at ./target/release/netzip_cli.
netzip list https://example.com/archive.zip
# or with the shorter alias
netzip l https://example.com/archive.zipThis will display a table with file paths, compressed sizes, and uncompressed sizes.
# Extract specific files
netzip extract https://example.com/archive.zip file1.txt file2.txt
# or with the shorter alias
netzip x https://example.com/archive.zip file1.txt file2.txtAdd to your Cargo.toml:
[dependencies]
netzip = "0.1.0"
reqwest = "0.12.15"
tokio = { version = "1.44.1", features = ["full"] }use netzip::RemoteZip;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let url = "https://example.com/archive.zip";
let zip = RemoteZip::get(url).await?;
for record in zip.records() {
println!("{} - {} bytes", record.file_name, record.uncompressed_size);
}
Ok(())
}use netzip::RemoteZip;
use std::fs;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let url = "https://example.com/archive.zip";
let zip = RemoteZip::get(url).await?;
let files_to_extract = vec!["file1.txt".to_string(), "file2.txt".to_string()];
let extracted_files = zip.download_files(files_to_extract).await?;
for (file, content) in extracted_files {
fs::write(&file.file_name, content)?;
println!("Extracted: {}", file.file_name);
}
Ok(())
}- Fetch End of Central Directory - First, netzip downloads just the end of the ZIP file to locate the Central Directory.
- Download Central Directory - It then downloads only the Central Directory, which contains metadata about all files in the archive.
- Extract Specific Files - Finally, it downloads only the parts of the archive that contain the requested files. If necessary, the blob is decompressed.
- Stored (uncompressed)
- Deflate
- Deflate64
- netzip_parser: Low-level ZIP format parser
- netzip: Main library for HTTP-based ZIP access
- netzip_cli: Command-line interface
LGPLv3