pub struct MultipartSpec {
pub max_fields: u16,
pub max_files: u16,
pub max_file_bytes: u64,
pub max_text_field_bytes: u64,
pub max_total_bytes: u64,
pub allowed_content_types: Vec<String>,
pub lifecycle: UploadLifecycle,
}Expand description
multipart/form-data 的资源与类型限制。
allowed_content_types 只校验客户端声明的媒体类型,不能替代 Handler 对文件魔数、
内容和业务格式的验证;其中唯一允许的通配写法 "*/*" 表示跳过该校验(对齐 TS
导入端点只按扩展名判断文件类型的行为)。
Fields§
§max_fields: u16非文件表单字段数量上限。
max_files: u16文件字段数量上限。
max_file_bytes: u64单文件字节上限。
max_text_field_bytes: u64单个文本(非文件)表单字段的字节上限;不得超过 max_total_bytes。
max_total_bytes: u64整个 multipart body 的字节上限。
allowed_content_types: Vec<String>允许的精确 MIME 类型;"*/*" 表示不校验文件 part 的客户端类型;
不允许空集合。
lifecycle: UploadLifecycle临时文件生命周期。
Implementations§
Source§impl MultipartSpec
impl MultipartSpec
Sourcepub fn max_fields(self, max_fields: u16) -> Self
pub fn max_fields(self, max_fields: u16) -> Self
设置非文件表单字段数量上限。
Sourcepub fn max_file_bytes(self, max_file_bytes: u64) -> Self
pub fn max_file_bytes(self, max_file_bytes: u64) -> Self
设置单文件字节上限。
Sourcepub fn max_text_field_bytes(self, max_text_field_bytes: u64) -> Self
pub fn max_text_field_bytes(self, max_text_field_bytes: u64) -> Self
设置单个文本(非文件)表单字段的字节上限。
Sourcepub fn max_total_bytes(self, max_total_bytes: u64) -> Self
pub fn max_total_bytes(self, max_total_bytes: u64) -> Self
设置整个 multipart body 的字节上限。
Trait Implementations§
Source§impl Clone for MultipartSpec
impl Clone for MultipartSpec
Source§impl Debug for MultipartSpec
impl Debug for MultipartSpec
Source§impl<'de> Deserialize<'de> for MultipartSpec
impl<'de> Deserialize<'de> for MultipartSpec
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
impl Eq for MultipartSpec
Source§impl JsonSchema for MultipartSpec
impl JsonSchema for MultipartSpec
Source§fn schema_name() -> String
fn schema_name() -> String
The name of the generated JSON Schema. Read more
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. 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 moreSource§impl PartialEq for MultipartSpec
impl PartialEq for MultipartSpec
Source§impl Serialize for MultipartSpec
impl Serialize for MultipartSpec
impl StructuralPartialEq for MultipartSpec
Auto Trait Implementations§
impl Forget for MultipartSpec
impl Freeze for MultipartSpec
impl Move for MultipartSpec
impl RefUnwindSafe for MultipartSpec
impl Send for MultipartSpec
impl Sync for MultipartSpec
impl Unpin for MultipartSpec
impl UnsafeUnpin for MultipartSpec
impl UnwindSafe for MultipartSpec
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.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