pub struct Multipart { /* private fields */ }
Available on crate feature
multipart
only.Expand description
An extractor that parses multipart/form-data
requests commonly used with
file uploads.
Errors
Example
use poem::{
error::{BadRequest, Error},
web::Multipart,
Result,
};
async fn upload(mut multipart: Multipart) -> Result<()> {
while let Some(field) = multipart.next_field().await? {
let data = field.bytes().await.map_err(BadRequest)?;
println!("{} bytes", data.len());
}
Ok(())
}
Implementations§
source§impl Multipart
impl Multipart
sourcepub async fn next_field(&mut self) -> Result<Option<Field>, ParseMultipartError>
pub async fn next_field(&mut self) -> Result<Option<Field>, ParseMultipartError>
Yields the next Field
if available.
Trait Implementations§
source§impl<'a> FromRequest<'a> for Multipart
impl<'a> FromRequest<'a> for Multipart
source§fn from_request<'life0, 'async_trait>(
req: &'a Request,
body: &'life0 mut RequestBody
) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where
Self: 'async_trait,
'a: 'async_trait,
'life0: 'async_trait,
fn from_request<'life0, 'async_trait>( req: &'a Request, body: &'life0 mut RequestBody ) -> Pin<Box<dyn Future<Output = Result<Self>> + Send + 'async_trait>>where Self: 'async_trait, 'a: 'async_trait, 'life0: 'async_trait,
Extract from request head and body.
Auto Trait Implementations§
impl !RefUnwindSafe for Multipart
impl Send for Multipart
impl Sync for Multipart
impl Unpin for Multipart
impl !UnwindSafe for Multipart
Blanket Implementations§
§impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedExplicit<'a, E> for Twhere T: 'a,
§impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere
T: 'a,
impl<'a, T, E> AsTaggedImplicit<'a, E> for Twhere T: 'a,
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> FutureExt for T
impl<T> FutureExt for T
source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> TowerCompatExt for T
impl<T> TowerCompatExt for T
source§fn compat<ResBody, Err, Fut>(self) -> TowerCompatEndpoint<Self>where
ResBody: HttpBody + Send + 'static,
ResBody::Data: Into<Bytes> + Send + 'static,
ResBody::Error: StdError + Send + Sync + 'static,
Err: Into<Error>,
Self: Service<Request<Body>, Response = Response<ResBody>, Error = Err, Future = Fut> + Clone + Send + Sync + Sized + 'static,
Fut: Future<Output = Result<Response<ResBody>, Err>> + Send + 'static,
fn compat<ResBody, Err, Fut>(self) -> TowerCompatEndpoint<Self>where ResBody: HttpBody + Send + 'static, ResBody::Data: Into<Bytes> + Send + 'static, ResBody::Error: StdError + Send + Sync + 'static, Err: Into<Error>, Self: Service<Request<Body>, Response = Response<ResBody>, Error = Err, Future = Fut> + Clone + Send + Sync + Sized + 'static, Fut: Future<Output = Result<Response<ResBody>, Err>> + Send + 'static,
Available on crate feature
tower-compat
only.Converts a tower service to a poem endpoint.