forms - Parsing HTTP multipart POST using a struct in Rocket -


i want parse http post in rocket using struct. upon submitting form fails.

i read body data example , have code.

#[derive(fromform)] struct convertfile {     name: string,     filename: string }  #[post("/submit", format = "multipart/form-data", data = "<form>")] fn submit(form: form<convertfile>) {     println!("form field: {}", form.get().name); } 

i submit using curl:

curl -h "content-type: multipart/form-data" -f "name=claus" -f "filename=claus.jpg" http://localhost:8000/submit 

and rocket console responds with

multipart/form-data; boundary=------------------------8495649d6ed34d20:     => matched: post /submit multipart/form-data     => warning: form data not have form content type.     => outcome: forward     => error: no matching routes post /submit multipart/form-data; boundary=------------------------8495649d6ed34d2.     => warning: responding 404 not found catcher.     => response succeeded. 

i want submit file hence multipart/form-data. when trying find reason, used string in struct make simpler. first responds matched: , no matching routes.

this simpler post works:

#[post("/convert", format = "text/plain", data = "<file>")] fn convert_file(file: string) {     println!("file: {}", file); } 

i using latest nightly rust rustup.

what doing wrong?

rocket not yet support multipart forms.

you can see tracking issue here: https://github.com/sergiobenitez/rocket/issues/106

a possible workaround given in answer: how parse multipart forms using abonander/multipart rocket?


Comments

Popular posts from this blog

node.js - Node js - Trying to send POST request, but it is not loading javascript content -

javascript - Replicate keyboard event with html button -

javascript - Web audio api 5.1 surround example not working in firefox -