Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

web/clients/download/basic doesnt handle binary files #644

Open
barrowsys opened this issue Mar 22, 2021 · 2 comments · May be fixed by #645
Open

web/clients/download/basic doesnt handle binary files #644

barrowsys opened this issue Mar 22, 2021 · 2 comments · May be fixed by #645

Comments

@barrowsys
Copy link

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)?;
@stappersg
Copy link

Looks good to me. Asking to @barrowsys to make a merge request. For the fame of being in the git commit log.

barrowsys added a commit to barrowsys/rust-cookbook that referenced this issue Apr 6, 2021
barrowsys added a commit to barrowsys/rust-cookbook that referenced this issue Apr 6, 2021
barrowsys added a commit to barrowsys/rust-cookbook that referenced this issue Apr 6, 2021
barrowsys added a commit to barrowsys/rust-cookbook that referenced this issue Apr 6, 2021
@barrowsys barrowsys linked a pull request Apr 6, 2021 that will close this issue
10 tasks
@barrowsys
Copy link
Author

barrowsys commented Apr 6, 2021

git is painful but its #645

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants