Open barrowsys opened 3 years ago
https://github.com/rust-lang-nursery/rust-cookbook/blob/master/src/web/clients/download/basic.md doesnt work if trying to download a binary file (such as an image). Might want to either point this out or modify the example to handle all data.
Doesn't work:
use std::io::copy; // ... let content = response.text().await?; copy(&mut content.as_bytes(), &mut dest)?;
Does work:
use std::io::Write; // ... let content = response.bytes().await()?; dest.write_all(&content)?;
Looks good to me. Asking to @barrowsys to make a merge request. For the fame of being in the git commit log.
git is painful but its #645
https://github.com/rust-lang-nursery/rust-cookbook/blob/master/src/web/clients/download/basic.md doesnt work if trying to download a binary file (such as an image). Might want to either point this out or modify the example to handle all data.
Doesn't work:
Does work: