我需要下载一个60MB的ZIP文件,并提取其中唯一的文件。我希望使用流来下载和提取它。如何使用Rust实现这个功能?
fn main () {
let mut res = reqwest::get("myfile.zip").unwrap();
// extract the response body to myfile.txt
}
在Node.js中,我会这样做:
http.get('myfile.zip', response => {
response.pipe(unzip.Parse())
.on('entry', entry => {
if (entry.path.endsWith('.txt')) {
entry.pipe(fs.createWriteStream('myfile.txt'))
}
})
})