pub struct UploadFileInfo {
pub name: String,
pub size: u64,
pub extension: String,
pub tmp_name: PathBuf,
pub error: i32,
pub is_internal: bool,
}Expand description
上传文件信息 — 对齐 PHP Server::setUploadFileByReal 中的 $fileInfo 数组
PHP 第 45-59 行:
public function setUploadFileByReal($filePath, $extension) {
$this->isInternal = true;
$this->fileInfo = [
'name' => basename($filePath),
'size' => filesize($filePath),
'extension' => $extension,
'tmp_name' => $filePath,
'error' => 0,
'isInternal' => $this->isInternal
];
$this->fileName = 'storage/'.date('Ymd') ."/". $this->fileInfo['name'];
}Fields§
§name: String文件名(对齐 PHP name = basename($filePath))
size: u64文件大小(字节,对齐 PHP size = filesize($filePath))
extension: String扩展名(对齐 PHP extension)
tmp_name: PathBuf临时文件路径(对齐 PHP tmp_name)
error: i32错误码(对齐 PHP error,0 表示无错误)
is_internal: bool是否内部上传(对齐 PHP isInternal)
Implementations§
Source§impl UploadFileInfo
impl UploadFileInfo
Sourcepub fn from_uploaded_file(
file: &UploadedFile,
) -> Result<UploadFileInfo, UploadError>
pub fn from_uploaded_file( file: &UploadedFile, ) -> Result<UploadFileInfo, UploadError>
从 UploadedFile 创建文件信息 — 对齐 PHP Server::setUploadFile 的隐式行为
PHP setUploadFile 直接将 Request::file($name) 赋给 $this->file,
然后调用 buildSaveName() 生成文件名。
Rust 端将 UploadedFile 转换为 UploadFileInfo。
Sourcepub fn from_real_path<P>(
path: P,
extension: &str,
) -> Result<UploadFileInfo, UploadError>
pub fn from_real_path<P>( path: P, extension: &str, ) -> Result<UploadFileInfo, UploadError>
从真实路径创建文件信息 — 对齐 PHP Server::setUploadFileByReal
PHP 行为:isInternal = true,name = basename($filePath),size = filesize($filePath)。
Trait Implementations§
Source§impl Clone for UploadFileInfo
impl Clone for UploadFileInfo
Source§fn clone(&self) -> UploadFileInfo
fn clone(&self) -> UploadFileInfo
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreAuto Trait Implementations§
impl Freeze for UploadFileInfo
impl RefUnwindSafe for UploadFileInfo
impl Send for UploadFileInfo
impl Sync for UploadFileInfo
impl Unpin for UploadFileInfo
impl UnsafeUnpin for UploadFileInfo
impl UnwindSafe for UploadFileInfo
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.