pub struct UploadedFile {
pub name: String,
pub content_type: String,
pub size: usize,
pub data: Bytes,
}Expand description
A single uploaded file extracted from a multipart request.
Fields§
§name: StringOriginal file name from the upload.
content_type: StringMIME content type (defaults to application/octet-stream).
size: usizeSize in bytes.
data: BytesRaw file bytes.
Implementations§
Source§impl UploadedFile
impl UploadedFile
Sourcepub async fn from_field(field: Field) -> Result<Self>
pub async fn from_field(field: Field) -> Result<Self>
Build an UploadedFile by consuming an axum multipart field.
Reads the entire field body into memory. Prefer using MultipartRequest
rather than calling this directly; it is public for advanced use cases
that need to process fields individually.
§Errors
Returns a 400 Bad Request error if the field body cannot be read.
Sourcepub fn extension(&self) -> Option<String>
pub fn extension(&self) -> Option<String>
Returns the file extension from the original filename in lowercase, without the leading dot.
Returns None if the filename has no extension (e.g. "readme") or is empty.
For compound extensions such as "archive.tar.gz", only the last component ("gz")
is returned.
Sourcepub fn validate(&self) -> UploadValidator<'_>
pub fn validate(&self) -> UploadValidator<'_>
Start building a fluent validation chain for this file.
Returns an UploadValidator that can be used to
check size and content type. Call
UploadValidator::check to finalize and
collect any violations.