Complete source code:
use std::fs::File;
use std::io;
fn main() {
let save_file_path = "temp.zip";
let download_url = "https://github.com/Aaron009/temp_rust_web_download/raw/main/wwwroot/temp.zip";
let resp = reqwest::blocking::get(download_url).expect("request failed");
let body = resp.text().expect("body invalid");
let mut out = File::create(save_file_path).expect("failed to create file");
let mut body_bytes = body.as_bytes();
io::copy(&mut body_bytes, &mut out).expect("failed to copy content");
println!("download completed!");
}
I use "Beyond Comparison" to compare screenshots as follows:
As shown in the figure, it is found that the file size is different, and the file size marked in red is also different. what is the reason?