diff options
Diffstat (limited to 'src/client.rs')
-rw-r--r-- | src/client.rs | 17 |
1 files changed, 12 insertions, 5 deletions
diff --git a/src/client.rs b/src/client.rs index 374cfb2..3dbca36 100644 --- a/src/client.rs +++ b/src/client.rs @@ -23,6 +23,7 @@ use reqwest::{ }; use serde::Serialize; use serde_urlencoded; +use std::collections::BTreeMap; use std::io::Read; use abook::AbookFetcher; use abconfig::ABConfigFetcher; @@ -133,17 +134,23 @@ impl Client { } } - pub fn post_multipart<T>(&self, path: &str, _data: &T, _files: &Vec<&str>) -> Result<String, Error> - where T: Serialize, + pub fn post_multipart(&self, path: &str, data: &BTreeMap<&str, &str>, files: &Vec<&str>) -> Result<String, Error> { let url = self.url(path, &()); - let f = reqwest::multipart::Form::new() - .text("balle", "klorin"); + let mut form = reqwest::multipart::Form::new(); + + for (key, value) in data.iter() { + form = form.text(key.to_string(), value.to_string()); + } + + for f in files.iter() { + form = form.file("files", f).unwrap(); + } let res = self.inner.post(&url) .basic_auth(self.user.clone(), Some(self.pw.clone())) .header(CONTENT_TYPE, "multipart/form-data") - .multipart(f) + .multipart(form) .send()?; match res.status() { |