download example using bytes instead of text

This commit is contained in:
Fran Tufro 2022-07-06 08:33:58 -03:00
parent 752b035c1a
commit a849cd6c47

View file

@ -11,8 +11,8 @@ The temporary directory is automatically removed on program exit.
```rust,edition2018,no_run
use error_chain::error_chain;
use std::io::copy;
use std::fs::File;
use std::io::Write;
use tempfile::Builder;
error_chain! {
@ -41,8 +41,8 @@ async fn main() -> Result<()> {
println!("will be located under: '{:?}'", fname);
File::create(fname)?
};
let content = response.text().await?;
copy(&mut content.as_bytes(), &mut dest)?;
let content = response.bytes().await?;
dest.write(&content)?;
Ok(())
}
```