actix-web
actix-web copied to clipboard
use actix_multipart to get field name and value deserialized to struct
I have looked through actix_multipart
documentation, and I couldn't find if there is a method to get the field name and value to be deserialized to a struct
I have use this
let mut filename: Option<String> = None;
// iterate over multipart stream
while let Ok(Some(mut field)) = payload.try_next().await {
let content_type = field.content_disposition();
let name = content_type.get_filename().unwrap();
filename = Some(name.to_string());
// Field in turn is stream of *Bytes* object
while let Some(chunk) = field.next().await {
let data = chunk.unwrap();
bytes.append(&mut data.to_vec());
}
}