ThorstenHans / blog-comments

0 stars 0 forks source link

weekly-rust-trivia-download-an-image-to-a-file/ #13

Open utterances-bot opened 1 year ago

utterances-bot commented 1 year ago

Weekly Rust Trivia: How to Download an Image to a File · Thorsten Hans' blog

Weekly Rust Trivia 🦀: This week, we download an image from the web and store it in a file

https://www.thorsten-hans.com/weekly-rust-trivia-download-an-image-to-a-file/

emanguy commented 1 year ago

You async example is actually doing a blocking file write and requires you to load the whole image into memory before writing it to a file.

A better way to do that would be to have reqwest give you a byte stream and write to the file with Tokio's async IO library as shown in this stack overflow answer: https://stackoverflow.com/a/74283625

ThorstenHans commented 1 year ago

This is great feedback! Thanks