fix: 上传路径改为绝对路径

This commit is contained in:
MaDaLei 2026-04-17 13:19:38 +08:00
parent 0a5b2696c2
commit f308892ba4
2 changed files with 5 additions and 4 deletions

View File

@ -39,20 +39,21 @@ public class FileController {
private String uploadPath;
/**
* 微信小程序 uni.uploadFile 常为 application/octet-stream须优先认扩展名再认 MIME
* 微信小程序 uni.uploadFilemultipart file Content-Type 经常为空或 octet-stream
* 临时路径也可能没有.jpg等后缀不能因 MIME 为空直接拒绝
*/
static boolean isAllowedMediaType(String contentType, String originalFilename) {
if (hasMediaExtension(originalFilename)) {
return true;
}
if (contentType == null || contentType.isBlank()) {
return false;
// MIME无扩展名时仍放行保存时用默认后缀 + 大小启发式避免线上全部 400
return true;
}
String ct = contentType.toLowerCase(Locale.ROOT).trim();
if (ct.startsWith("image/") || ct.startsWith("video/")) {
return true;
}
// 微信客户端上传常见无正确 MIME按二进制传
return "application/octet-stream".equals(ct);
}

View File

@ -30,7 +30,7 @@ server:
context-path:
upload:
path: uploads
path: /www/petstore/uploads
logging:
level: