diff options
| author | Mariot Tsitoara <[email protected]> | 2021-01-03 22:40:38 +0100 |
|---|---|---|
| committer | Mariot Tsitoara <[email protected]> | 2021-01-03 22:40:38 +0100 |
| commit | eea1bf4fbee230f16fd17a16f3d52167d40c2048 (patch) | |
| tree | 553a982818bc07568d474b2dc2f6cd32605f0a83 | |
| parent | Add reload and sleep actions (diff) | |
| download | chan-downloader-eea1bf4fbee230f16fd17a16f3d52167d40c2048.tar.xz chan-downloader-eea1bf4fbee230f16fd17a16f3d52167d40c2048.zip | |
Use bytes instead of text for image saving
| -rw-r--r-- | Cargo.toml | 2 | ||||
| -rw-r--r-- | src/cli.yml | 2 | ||||
| -rw-r--r-- | src/lib.rs | 6 |
3 files changed, 5 insertions, 5 deletions
@@ -1,7 +1,7 @@ [package] name = "chan-downloader" description = "CLI to download all images/webms of a 4chan thread" -version = "0.1.6" +version = "0.1.7" authors = ["Mariot Tsitoara <[email protected]>"] edition = "2018" license = "MIT" diff --git a/src/cli.yml b/src/cli.yml index 6b0ca8f..4819f45 100644 --- a/src/cli.yml +++ b/src/cli.yml @@ -1,5 +1,5 @@ name: chan-downloader -version: "0.1.6" +version: "0.1.7" author: "Mariot Tsitoara <[email protected]>" about: CLI to download all images/webms of a 4chan thread args: @@ -9,7 +9,7 @@ extern crate regex; extern crate reqwest; use std::fs::File; -use std::io::copy; +use std::io::{copy, Cursor}; use log::info; use regex::{CaptureMatches, Regex}; @@ -39,8 +39,8 @@ pub fn save_image(url: &str, path: &str, client: &Client) -> Result<String, Erro if response.status().is_success() { let mut dest = File::create(path).unwrap(); - let content = response.text()?; - copy(&mut content.as_bytes(), &mut dest).unwrap(); + let mut content = Cursor::new(response.bytes().unwrap()); + copy(&mut content, &mut dest).unwrap(); } info!("Saved image to: {}", path); Ok(String::from(path)) |