I'm attempting to send POST request by curl with an array of map. How it should be written?
I wrote:
curl -X POST -H "Content-Type: multipart/form-data" -F files[]="name=\"qqq\"" localhost:8080/upload
But it returns a Found field with unexpected name or type
error.
By the way, How it would be with uncommented stroke with two fields in each map? for file's name and for file's data ?
fn main() -> Result<(), failure::Error> {
let form = Form::new()
.field("files", Field::array(
Field::map()
.field("name", Field::text())
// .field("file", Field::file(Gen))
.finalize()
));
println!("{:?}", form);
HttpServer::new(move || {
App::new()
.service(resource("/upload")
.data(form.clone())
.route(post()
.to(upload_multipart)
)
)
})
.bind("127.0.0.1:8080")?
.run()?;
Ok(())
}