【发布时间】:2018-05-22 15:19:07
【问题描述】:
我需要下载一个 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'))
}
})
})
【问题讨论】:
-
你看过箱子拉链了吗? github.com/mvdnes/zip-rs
-
我做过,但我刚刚开始使用 rust,reqwest + zip 示例真的会派上用场。
-
您是否考虑过接受这个问题的答案或开始悬赏?