aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/cli.yml2
-rw-r--r--src/lib.rs6
2 files changed, 4 insertions, 4 deletions
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:
diff --git a/src/lib.rs b/src/lib.rs
index ec81c3b..cc16e09 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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))