Open GenerelSchwerz opened 2 years ago
A slight update:
This could be easily resolved if there was an option to specify the boundary of each part manually. I'm not sure if I should open a pull request or not, since I'm relatively new to rust, but if I should please let me know.
This is old but the solution I found was to use the mpart-async library, specify my own content type header, and then use the body function with reqwest.
Here is an example:
use mpart_async::client::MultipartRequest;
use mpart_async::filestream::FileStream;
use reqwest::{Body, Client, get, header};
use reqwest::header::CONTENT_TYPE;
pub async fn update_name(
fields: Vec<(String, String)>,
) -> Result<ResultStruct> {
let mut mpart = MultipartRequest::<FileStream>::new("------WebKitFormBoundaryhSUnLTjMGhbdZ0Qg");
for (name, value) in fields {
mpart.add_field(name, value);
}
let res = Client::new()
.post(format!("website"))
.header(
CONTENT_TYPE,
format!("multipart/form-data; boundary={}", mpart.get_boundary()),
)
.body(Body::wrap_stream(mpart))
.send()
.await?
.json::<ResultStruct>()
.await?;
Ok(res)
}
I'm facing an issue when using the reqwest::multipart part of this library. I'm currently attempting to make a POST request to a website that only accepts
Content-Type: multipart/form-data; boundary=----WebKitFormBoundaryXXXXXXXXXXXX
.Reqwest's current support for multipart data automatically derives the boundary and such using a standard that does not comply with what WebkitFormBoundary desires.
Current multipart boundary generation:
The request I'm attempting to emulate:
Is there any alternative for sending multipart forms, or to manually construct them?