pub struct UploadedFile { /* private fields */ }Expand description
由受信传输层创建的请求作用域上传文件。
临时路径只在当前 Handler 执行期间有效。需要持久化时调用 copy_to
或使用受控存储服务显式转存;保存本路径供请求结束后使用是无效的。
§受信边界(C-1)
实例只能由 multipart 传输层在服务端构造的 JSON 反序列化得到:传输层在构造处注入
temp_root(请求作用域临时目录)。客户端 JSON 缺省该字段,反序列化后为 None,
copy_to 一律拒绝,防止普通 JSON Action 伪造 path 读取本地文件。
构建期 AppBuilder 另有双向校验:含二进制文件字段的输入必须声明 multipart,
multipart Action 必须至少声明一个文件字段。
Implementations§
Source§impl UploadedFile
impl UploadedFile
Sourcepub fn field_name(&self) -> &str
pub fn field_name(&self) -> &str
返回 multipart 字段名。
Sourcepub fn original_filename(&self) -> &str
pub fn original_filename(&self) -> &str
返回去除客户端路径片段后的原始文件名。
Sourcepub fn content_type(&self) -> &str
pub fn content_type(&self) -> &str
返回已通过 Action 白名单校验的客户端声明 MIME 类型。
Trait Implementations§
Source§impl Clone for UploadedFile
impl Clone for UploadedFile
Source§impl Debug for UploadedFile
impl Debug for UploadedFile
Source§impl<'de> Deserialize<'de> for UploadedFile
impl<'de> Deserialize<'de> for UploadedFile
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Source§impl JsonSchema for UploadedFile
impl JsonSchema for UploadedFile
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn json_schema(_generator: &mut SchemaGenerator) -> Schema
fn json_schema(_generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn is_referenceable() -> bool
fn is_referenceable() -> bool
Whether JSON Schemas generated for this type should be re-used where possible using the
$ref keyword. Read moreAuto Trait Implementations§
impl Forget for UploadedFile
impl Freeze for UploadedFile
impl Move for UploadedFile
impl RefUnwindSafe for UploadedFile
impl Send for UploadedFile
impl Sync for UploadedFile
impl Unpin for UploadedFile
impl UnsafeUnpin for UploadedFile
impl UnwindSafe for UploadedFile
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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 more