minreq icon indicating copy to clipboard operation
minreq copied to clipboard

How I can send files with minreq? :(

Open 0xS4D opened this issue 3 years ago • 1 comments

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 :(

0xS4D avatar Oct 27 '22 11:10 0xS4D

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!

neonmoe avatar Oct 27 '22 11:10 neonmoe