pub struct UploadedFile {
pub field_name: String,
pub file_name: Option<String>,
pub content_type: Option<String>,
pub bytes: Bytes,
}Expand description
A single uploaded file extracted from a multipart/form-data request.
Fields§
§field_name: StringName of the form field this file was attached to (e.g. "avatar").
file_name: Option<String>Original filename from the part’s Content-Disposition header, if present.
content_type: Option<String>MIME type from the part headers, if present.
bytes: BytesBuffered file content.
Implementations§
Source§impl UploadedFile
impl UploadedFile
Sourcepub fn extension(&self) -> Option<&str>
pub fn extension(&self) -> Option<&str>
File extension derived from file_name via std::path::Path::extension().
Returns None when file_name is None or has no extension.
Sourcepub async fn store(&self, disk: &Disk, path: &str) -> Result<(), Error>
pub async fn store(&self, disk: &Disk, path: &str) -> Result<(), Error>
Persist the buffered bytes to the given storage disk.
The content type stored alongside the object defaults to
"application/octet-stream" when this file has no declared MIME type.
The caller is responsible for selecting the disk via
storage.disk("public")? (or another configured name).
§Security
path is passed verbatim to the storage driver. Callers MUST sanitize
any user-supplied component (e.g. self.file_name) before constructing
the path — this method does not perform path-traversal checks.
Trait Implementations§
Source§impl Clone for UploadedFile
impl Clone for UploadedFile
Source§fn clone(&self) -> UploadedFile
fn clone(&self) -> UploadedFile
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl !Freeze for UploadedFile
impl RefUnwindSafe for UploadedFile
impl Send for UploadedFile
impl Sync for UploadedFile
impl Unpin for UploadedFile
impl UnsafeUnpin for UploadedFile
impl UnwindSafe for UploadedFile
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
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: 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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more