skip to content
logo 夕舞八弦

Download big file with reqwest

/ 1 min read

use tokio::fs

Originally posted by @jtara1 in comment

use std::borrow::BorrowMut;
use tokio::io::AsyncWriteExt;
let mut response = client.get(dbg!(url)).send().await?;
let mut file = tokio::fs::File::create(path).await?;
while let Some(mut item) = response.chunk().await? {
file.write_all_buf(item.borrow_mut()).await?;
}

use std::fs

use std::borrow::BorrowMut;
let mut response = client.get(dbg!(url)).send().await?;
let mut file = std::fs::File::create(path)?;
while let Some(mut item) = response.chunk().await? {
file.write_all(item.borrow_mut())?;
}