兼容带参数的 PNG 内容类型
解析 multipart Content-Type 的媒体类型部分,接受合法的 image/png 参数。
This commit is contained in:
@@ -278,7 +278,17 @@ async fn read_multipart_image(
|
||||
name: &str,
|
||||
total_bytes: &mut usize,
|
||||
) -> Result<RawImageData, AppError> {
|
||||
let mime_type = field.content_type().unwrap_or_default().to_string();
|
||||
let mime_type = field
|
||||
.content_type()
|
||||
.map(|value| {
|
||||
value
|
||||
.split(';')
|
||||
.next()
|
||||
.unwrap_or_default()
|
||||
.trim()
|
||||
.to_string()
|
||||
})
|
||||
.unwrap_or_default();
|
||||
if !mime_type.eq_ignore_ascii_case("image/png") {
|
||||
return Err(bad_request(format!("{name} 必须为 image/png")));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user