use bytes::BufMut; use futures_util::TryStreamExt; use warp::multipart::FormData; use warp::Filter;
#[tokio::main] asyncfn main() { // Running curl -F file=@.gitignore 'localhost:3030/' should print [("file", ".gitignore", "\n/target\n**/*.rs.bk\nCargo.lock\n.idea/\nwarp.iml\n")] let route = warp::multipart::form().and_then(|form: FormData| asyncmove { let field_names: Vec<_> = form
.and_then(|mut field| asyncmove { letmut bytes: Vec<u8> = Vec::new();
// field.data() only returns a piece of the content, you should call over it until it replies None whilelet Some(content) = field.data().await { let content = content.unwrap();
bytes.put(content);
}
Ok((
field.name().to_string(),
field.filename().unwrap().to_string(),
String::from_utf8_lossy(&*bytes).to_string(),
))
})
.try_collect()
.await
.unwrap();
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.