Open frantufro opened 2 years ago
The current example for downloading files interprets the response as text, and then turns it into bytes.
let content = response.text().await?; copy(&mut content.as_bytes(), &mut dest)?;
This is fine if you're downloading text files, but it will corrupt binary files (I found this issue when downloading PNGs).
In order to fix this I suggest using response.bytes() directly.
response.bytes()
let content = response.bytes().await?; dest.write(&content)?;
This is how I ended up implementing it and it works great.
The current example for downloading files interprets the response as text, and then turns it into bytes.
This is fine if you're downloading text files, but it will corrupt binary files (I found this issue when downloading PNGs).
In order to fix this I suggest using
response.bytes()
directly.This is how I ended up implementing it and it works great.