/// uploads an image an returns the image id
uploads an image an returns the image id
uploads an image an returns the image id
pub fn upload_image<P: AsRef<Path>>(
        &self,
        group_name: &str,
        path: P,
        filename: String,
    ) -> FarmResult<String> {
        let url_path = format!("group/{}/image", group_name);
        let target_file = PathBuf::from(path.as_ref());
        let form = multipart::Form::new()
            .file(filename.clone(), target_file)
            .expect("could not create multipart for image");
        let rb = self.post(&url_path).multipart(form);
        let resp = rb.send()?;
        let mut image_ids = resp.json::<ImageUploadResponse>()?.image_ids;
        if image_ids.len() != 1 || !image_ids.contains_key(&filename) {
            return Err(FarmError::InvalidResponse {
                message: format!(
                    "Response has invalid length or does not contain image id for '{}'",
                    filename
                ),
            });
        }
        Ok(image_ids.remove(&filename).unwrap())
    }
pub fn upload_image < P : AsRef < Path > > ( & self , group_name : & str , path : P , filename : String , ) -> FarmResult < String > { let url_path = format ! ( " " group_name ) ; let target_file = PathBuf :: from ( path . as_ref ( ) ) ; let form = multipart :: Form :: new ( ) . file ( filename . clone ( ) , target_file ) . expect ( " " ) ; let rb = self . post ( & url_path ) . multipart ( form ) ; let resp = rb . send ( ) ? ; let mut image_ids = resp . json :: < ImageUploadResponse > ( ) ? . image_ids ; if image_ids . len ( ) != 1 || ! image_ids . contains_key ( & filename ) { return Err ( FarmError :: InvalidResponse { message : format ! ( " " filename ) , } ) ; } Ok ( image_ids . remove ( & filename ) . unwrap ( ) ) }
uploads an image an returns the image id
uploads an image an returns the image id
&self
group_name
&str
path
P
filename
String