pub struct File { /* private fields */ }Expand description
A tempfile wrapper that includes the original filename
Implementations§
Source§impl File
impl File
pub fn into_inner(self) -> NamedTempFile ⓘ
Sourcepub fn original_file_name(&self) -> Option<&str>
pub fn original_file_name(&self) -> Option<&str>
The filename provided in the multipart/form-data request
Sourcepub fn sanitized_file_name(&self) -> &str
pub fn sanitized_file_name(&self) -> &str
The sanitized version of the original file name, or generated name if none provided
Sourcepub fn persist<P: AsRef<Path>>(self, dir: P) -> Result<PathBuf, Error>
👎Deprecated since 0.5.4: Please use the ‘persist_in’ function instead
pub fn persist<P: AsRef<Path>>(self, dir: P) -> Result<PathBuf, Error>
Persist the tempfile to an existing directory. Uses the sanitized file name and returns the full path
NOTE: Because of how temporary file is stored, it cannot be persisted across filesystems.
Also neither the file contents nor the containing directory are
synchronized, so the update may not yet have reached the disk when
persist returns.
Sourcepub fn persist_in<P: AsRef<Path>>(self, dir: P) -> Result<PathBuf, Error>
pub fn persist_in<P: AsRef<Path>>(self, dir: P) -> Result<PathBuf, Error>
Persist the tempfile to an existing directory. Uses the sanitized file name and returns the full path
NOTE: Because of how temporary file is stored, it cannot be persisted across filesystems.
Also neither the file contents nor the containing directory are
synchronized, so the update may not yet have reached the disk when
persist_in returns.
Sourcepub fn persist_at<P: AsRef<Path>>(self, path: P) -> Result<File, Error>
pub fn persist_at<P: AsRef<Path>>(self, path: P) -> Result<File, Error>
Persist the tempfile at the specified file path.
NOTE: Because of how temporary file is stored, it cannot be persisted across filesystems.
Also neither the file contents nor the containing directory are
synchronized, so the update may not yet have reached the disk when
persist_at returns.
pub fn new( file: NamedTempFile, original_file_name: Option<String>, mime_type: Option<&Mime>, ) -> Self
pub fn new_with_file_name( file: NamedTempFile, original_file_name: String, ) -> Self
Source§impl File
impl File
Sourcepub fn persist_with_permissions<P: AsRef<Path>>(
self,
dir: P,
mode: u32,
) -> Result<PathBuf, Error>
pub fn persist_with_permissions<P: AsRef<Path>>( self, dir: P, mode: u32, ) -> Result<PathBuf, Error>
Persist the tempfile with specific permissions on Unix
NOTE: Because of how temporary file is stored, it cannot be persisted across filesystems.
Also neither the file contents nor the containing directory are
synchronized, so the update may not yet have reached the disk when
persist_with_permissions returns.
Sourcepub fn persist_with_open_permissions<P: AsRef<Path>>(
self,
dir: P,
) -> Result<PathBuf, Error>
pub fn persist_with_open_permissions<P: AsRef<Path>>( self, dir: P, ) -> Result<PathBuf, Error>
Persist the tempfile with 644 permissions on Unix
NOTE: Because of how temporary file is stored, it cannot be persisted across filesystems.
Also neither the file contents nor the containing directory are
synchronized, so the update may not yet have reached the disk when
persist_with_open_permissions returns.