pub struct UploadConfig {
pub upload_dir: PathBuf,
pub max_file_size: usize,
pub allowed_extensions: Vec<String>,
pub overwrite: bool,
pub unique_names: bool,
}Expand description
Upload configuration
Fields§
§upload_dir: PathBufUpload directory (where files will be stored)
max_file_size: usizeMaximum file size in bytes (default: 100MB)
allowed_extensions: Vec<String>Allowed file extensions (empty = all allowed)
overwrite: boolOverwrite existing files
unique_names: boolGenerate unique filenames
Implementations§
Source§impl UploadConfig
impl UploadConfig
Sourcepub fn with_max_size(self, size: usize) -> Self
pub fn with_max_size(self, size: usize) -> Self
Set max file size
Sourcepub fn with_extensions(self, extensions: Vec<String>) -> Self
pub fn with_extensions(self, extensions: Vec<String>) -> Self
Set allowed extensions
Sourcepub fn with_overwrite(self, overwrite: bool) -> Self
pub fn with_overwrite(self, overwrite: bool) -> Self
Set overwrite mode
Sourcepub fn with_unique_names(self, unique: bool) -> Self
pub fn with_unique_names(self, unique: bool) -> Self
Set unique names mode
Sourcepub fn is_extension_allowed(&self, filename: &str) -> bool
pub fn is_extension_allowed(&self, filename: &str) -> bool
Check if file extension is allowed
Sourcepub fn is_size_allowed(&self, size: usize) -> bool
pub fn is_size_allowed(&self, size: usize) -> bool
Check if file size is within limit
Sourcepub fn generate_unique_filename(&self, original: &str) -> String
pub fn generate_unique_filename(&self, original: &str) -> String
Generate unique filename
Trait Implementations§
Source§impl Clone for UploadConfig
impl Clone for UploadConfig
Source§fn clone(&self) -> UploadConfig
fn clone(&self) -> UploadConfig
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for UploadConfig
impl Debug for UploadConfig
Auto Trait Implementations§
impl Freeze for UploadConfig
impl RefUnwindSafe for UploadConfig
impl Send for UploadConfig
impl Sync for UploadConfig
impl Unpin for UploadConfig
impl UnsafeUnpin for UploadConfig
impl UnwindSafe for UploadConfig
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