This crate provides a wrapper for actix_multipart::Multipart
,
which may cause heavy dependencies.
It won't be used as a module of crate roa
until implementing a cleaner Multipart.
```rust,norun use asyncstd::fs::File; use asyncstd::io; use asyncstd::path::Path; use futures::stream::TryStreamExt; use futures::StreamExt; use roa::http::StatusCode; use roa::tcp::Listener; use roa::router::{Router, post}; use roa::{throw, App, Context}; use roa_multipart::MultipartForm; use std::error::Error as StdError;
async fn postfile(ctx: &mut Context) -> roa::Result { let mut form = ctx.form(); while let Some(item) = form.next().await { let field = item?; match field.contentdisposition() { None => throw!(StatusCode::BADREQUEST, "content disposition not set"), Some(contentdisposition) => match contentdisposition.getfilename() { None => continue, // ignore non-file field Some(filename) => { let path = Path::new("./upload"); let mut file = File::create(path.join(filename)).await?; io::copy(&mut field.intoasyncread(), &mut file).await?; } }, } } Ok(()) }
async fn main() -> Result<(), Box