minreq
minreq copied to clipboard
How I can send files with minreq? :(
let mut file = fs::File::open(&dir_temp.join(constants::TEMP_NAME)).unwrap();
let mut buffer = Vec::new();
file.read_to_end(&mut buffer).unwrap();
let response = minreq::post(constants::URL)
.with_header("Content-Type", "multipart/form-data")
.with_header("Content-Length", &buffer.len().to_string())
.with_body(buffer)
.send()
.unwrap();
I tried this but don't work :(
Multipart/form-data is its own format that presumably requires including something else than just the file buffer in the body. It's implemented by crates like multipart, which seems to need some integration with the http client (e.g. minreq) to work. I don't currently have time to implement that, but I would welcome a PR for a new feature that somehow added integration between minreq and multipart.
Tl;dr: currently not possible easily, as far as I know!