pub struct Upload {
pub field: String,
pub filename: Option<String>,
pub content_type: Option<String>,
pub data: Bytes,
}Expand description
One uploaded file (or any multipart part with a filename).
Prefer Upload::validate + Storage store/store_as for app uploads;
Self::save / Self::save_in write raw paths (no Storage / public URL).
Fields§
§field: String§filename: Option<String>§content_type: Option<String>§data: BytesImplementations§
Source§impl Upload
impl Upload
Sourcepub fn extension(&self) -> Option<String>
pub fn extension(&self) -> Option<String>
Lowercase extension from the client filename (no leading dot).
Sourcepub fn mime_type(&self) -> Option<String>
pub fn mime_type(&self) -> Option<String>
Primary MIME type without parameters (image/png; charset=utf-8 → image/png).
Sourcepub fn validate(&self, rules: &UploadRules) -> Result<()>
pub fn validate(&self, rules: &UploadRules) -> Result<()>
Apply UploadRules (empty / max size / extensions / mimes).
Sourcepub async fn save(&self, path: impl AsRef<Path>) -> Result<()>
pub async fn save(&self, path: impl AsRef<Path>) -> Result<()>
Write bytes to path (creates parent dirs).
Sourcepub async fn save_in(
&self,
dir: impl AsRef<Path>,
filename: &str,
) -> Result<PathBuf>
pub async fn save_in( &self, dir: impl AsRef<Path>, filename: &str, ) -> Result<PathBuf>
Save under dir / filename (rejects .. and absolute names).
Sourcepub fn suggested_name(&self) -> &str
pub fn suggested_name(&self) -> &str
Preferred download name: client filename or field name.
Trait Implementations§
Auto Trait Implementations§
impl !Freeze for Upload
impl RefUnwindSafe for Upload
impl Send for Upload
impl Sync for Upload
impl Unpin for Upload
impl UnsafeUnpin for Upload
impl UnwindSafe for Upload
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