fix: 文件上传接口调整

This commit is contained in:
MaDaLei 2026-04-17 14:11:26 +08:00
parent f9b5a7abb3
commit 6d154f1f9a
2 changed files with 6 additions and 1 deletions

View File

@ -96,7 +96,8 @@ public class FileController {
.body(new FileSystemResource(file)); .body(new FileSystemResource(file));
} }
@PostMapping("/image") /** produces 显式 UTF-8避免网关/客户端按 ISO-8859-1 解码导致 message 中文乱码 */
@PostMapping(value = "/image", produces = MediaType.APPLICATION_JSON_VALUE + ";charset=UTF-8")
public Map<String, Object> uploadImage(@RequestParam("file") MultipartFile file) { public Map<String, Object> uploadImage(@RequestParam("file") MultipartFile file) {
Map<String, Object> result = new HashMap<>(); Map<String, Object> result = new HashMap<>();

View File

@ -28,6 +28,10 @@ server:
port: 8080 port: 8080
servlet: servlet:
context-path: context-path:
encoding:
charset: UTF-8
enabled: true
force: true
# 与 multipart 一致,避免嵌入式 Tomcat 仍限制表单体积导致大视频 413 # 与 multipart 一致,避免嵌入式 Tomcat 仍限制表单体积导致大视频 413
tomcat: tomcat:
max-http-form-post-size: 200MB max-http-form-post-size: 200MB