pub struct File(pub UploadedFile);Expand description
File extractor for a single file upload.
This extractor gets a single file from a multipart form by field name.
The field name is specified via FileConfig extension on the request,
or defaults to “file”.
§Example
ⓘ
use fastapi_core::{File, FromRequest};
async fn upload(file: File) -> String {
format!("Received: {} ({} bytes)", file.filename(), file.size())
}Tuple Fields§
§0: UploadedFileImplementations§
Source§impl File
impl File
Sourcepub fn into_inner(self) -> UploadedFile
pub fn into_inner(self) -> UploadedFile
Get the underlying uploaded file.
Sourcepub fn inner(&self) -> &UploadedFile
pub fn inner(&self) -> &UploadedFile
Get a reference to the uploaded file.
Methods from Deref<Target = UploadedFile>§
Sourcepub fn field_name(&self) -> &str
pub fn field_name(&self) -> &str
Get the form field name.
Sourcepub fn content_type(&self) -> &str
pub fn content_type(&self) -> &str
Get the Content-Type.
Trait Implementations§
Source§impl FromRequest for File
impl FromRequest for File
Source§type Error = MultipartExtractError
type Error = MultipartExtractError
Error type when extraction fails.
Source§async fn from_request(
ctx: &RequestContext,
req: &mut Request,
) -> Result<Self, Self::Error>
async fn from_request( ctx: &RequestContext, req: &mut Request, ) -> Result<Self, Self::Error>
Extract a value from the request. Read more
Auto Trait Implementations§
impl Freeze for File
impl RefUnwindSafe for File
impl Send for File
impl Sync for File
impl Unpin for File
impl UnwindSafe for File
Blanket Implementations§
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, _span: NoopSpan) -> Self
fn instrument(self, _span: NoopSpan) -> Self
Instruments this future with a span (no-op when disabled).
Source§fn in_current_span(self) -> Self
fn in_current_span(self) -> Self
Instruments this future with the current span (no-op when disabled).