Update storage.js via upload script - 2026-08-24 09:30:38
This commit is contained in:
parent
c02aff38b3
commit
b5934aae02
13
storage.js
13
storage.js
|
|
@ -38,7 +38,18 @@ export async function uploadFile(customerId, file) {
|
|||
body: fd,
|
||||
});
|
||||
if (!res.ok) {
|
||||
throw new Error(`upload failed: ${res.status}`);
|
||||
let msg = `上传失败(HTTP ${res.status})`;
|
||||
try {
|
||||
const data = await res.json();
|
||||
if (data && data.error) msg = data.error;
|
||||
} catch (e) {
|
||||
// 响应不是JSON——说明请求可能根本没到Node这一层就被拦下了,最常见的原因是
|
||||
// Nginx反向代理的client_max_body_size(默认1MB)比文件小,直接返回了413的HTML错误页
|
||||
if (res.status === 413) {
|
||||
msg = '文件太大,被Nginx反向代理拦截了(默认限制1MB)。需要去Nginx配置里把client_max_body_size调大,改完执行 nginx -t 和 systemctl reload nginx';
|
||||
}
|
||||
}
|
||||
throw new Error(msg);
|
||||
}
|
||||
return res.json();
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue