fix: 上传路径改为绝对路径
This commit is contained in:
parent
0a5b2696c2
commit
f308892ba4
@ -39,20 +39,21 @@ public class FileController {
|
||||
private String uploadPath;
|
||||
|
||||
/**
|
||||
* 微信小程序 uni.uploadFile 常为 application/octet-stream;须优先认扩展名,再认 MIME。
|
||||
* 微信小程序 uni.uploadFile:multipart 里 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);
|
||||
}
|
||||
|
||||
|
||||
@ -30,7 +30,7 @@ server:
|
||||
context-path:
|
||||
|
||||
upload:
|
||||
path: uploads
|
||||
path: /www/petstore/uploads
|
||||
|
||||
logging:
|
||||
level:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user