i'm trying to send ImageBuffer that come from this library via curl-rust, in curl-rust there is send buffer option.
i don't know why, but my server receive invalid image file, here;s my current code :
extern crate camera_capture;
extern crate image;
// use std::fs::File;
// use std::path::Path;
use curl::easy::{Easy, Form};
fn main() {
let cam = camera_capture::create(0).unwrap();
let mut cam_iter = cam.fps(5.0).unwrap().start().unwrap();
let img = cam_iter.next().unwrap();
// let file_name = "test.png";
// let path = Path::new(&file_name);
// let _ = &mut File::create(&path).unwrap();
// img.save(&path).unwrap();
// println!("img saved to {}", file_name);
println!("sending image...");
let mut easy = Easy::new();
easy.url("http://localhost/upload").unwrap();
easy.post(true).unwrap();
let mut form = Form::new();
form.part("image").buffer("image.jpg", img.into_vec()).add().unwrap();
easy.httppost(form).unwrap();
easy.perform().unwrap();
println!("{}", easy.response_code().unwrap());
}
the form buffer can receive img.into_vec()
or img.into_raw()
but both are sending invalid file.