Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How I can send files with minreq? :( #83

Open
0xS4D opened this issue Oct 27, 2022 · 1 comment
Open

How I can send files with minreq? :( #83

0xS4D opened this issue Oct 27, 2022 · 1 comment
Labels
enhancement New feature or request

Comments

@0xS4D
Copy link

0xS4D commented Oct 27, 2022

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

@neonmoe
Copy link
Owner

neonmoe commented Oct 27, 2022

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 neonmoe added the enhancement New feature or request label Oct 27, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants