pub struct UploadFile {
pub field_name: String,
pub filename: String,
pub content_type: String,
/* private fields */
}Expand description
An uploaded file with metadata and FastAPI-style async file operations.
Fields§
§field_name: StringThe field name.
filename: StringThe original filename.
content_type: StringContent-Type of the file.
Implementations§
Source§impl UploadFile
impl UploadFile
Sourcepub fn from_part(part: Part) -> Option<UploadFile>
pub fn from_part(part: Part) -> Option<UploadFile>
Create a new UploadFile from a Part.
Returns None if the part is not a file.
Sourcepub fn from_part_with_spool_threshold(
part: Part,
spool_threshold: usize,
) -> Option<UploadFile>
pub fn from_part_with_spool_threshold( part: Part, spool_threshold: usize, ) -> Option<UploadFile>
Create a new UploadFile from a Part with a custom spool threshold.
Returns None if the part is not a file.
Sourcepub fn is_spooled(&self) -> bool
pub fn is_spooled(&self) -> bool
Returns true when this file has been spooled to a temporary file.
Sourcepub fn spooled_path(&self) -> Option<&Path>
pub fn spooled_path(&self) -> Option<&Path>
Path to the spooled temporary file, if this upload is backed by disk.
Sourcepub fn bytes(&self) -> Result<Vec<u8>, Error>
pub fn bytes(&self) -> Result<Vec<u8>, Error>
Read file contents without changing the current cursor.
Sourcepub async fn read(&mut self, size: Option<usize>) -> Result<Vec<u8>, Error>
pub async fn read(&mut self, size: Option<usize>) -> Result<Vec<u8>, Error>
Read from the current cursor position.
size = Some(n): read up tonbytessize = None: read until EOF
Sourcepub async fn write(&mut self, bytes: &[u8]) -> Result<usize, Error>
pub async fn write(&mut self, bytes: &[u8]) -> Result<usize, Error>
Write bytes at the current cursor position.
Returns the number of bytes written.
Sourcepub async fn seek(&mut self, position: SeekFrom) -> Result<u64, Error>
pub async fn seek(&mut self, position: SeekFrom) -> Result<u64, Error>
Move the current cursor.
Trait Implementations§
Source§impl Debug for UploadFile
impl Debug for UploadFile
Auto Trait Implementations§
impl Freeze for UploadFile
impl RefUnwindSafe for UploadFile
impl Send for UploadFile
impl Sync for UploadFile
impl Unpin for UploadFile
impl UnwindSafe for UploadFile
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> 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).