fix: 将工作流文档解析上限统一为 100MiB

- 前后端统一单文件与总大小限制为 100MiB

- 按实际读取字节数拦截超限文档并记录大小差异

- 补充存储、远程流与边界场景测试
This commit is contained in:
2026-07-31 14:52:06 +08:00
parent 4a0efe8879
commit 5c29ca9407
11 changed files with 588 additions and 66 deletions

View File

@@ -127,20 +127,20 @@ describe('workflowFileValue', () => {
});
it('上传前校验单文件大小限制', () => {
const acceptedFile = new File(
[new Uint8Array(20 * 1024 * 1024)],
'accepted.pdf',
);
const oversizedFile = new File(
[new Uint8Array(20 * 1024 * 1024 + 1)],
'large.pdf',
);
const acceptedFile = new File([], 'accepted.pdf');
const oversizedFile = new File([], 'large.pdf');
Object.defineProperty(acceptedFile, 'size', {
value: 100 * 1024 * 1024,
});
Object.defineProperty(oversizedFile, 'size', {
value: 100 * 1024 * 1024 + 1,
});
expect(() =>
validateWorkflowFileSelection([], [acceptedFile]),
).not.toThrow();
expect(() => validateWorkflowFileSelection([], [oversizedFile])).toThrow(
'单个文件不能超过 20.0 MB',
'单个文件不能超过 100.0 MB',
);
});
@@ -149,13 +149,13 @@ describe('workflowFileValue', () => {
{
fileName: 'existing.pdf',
filePath: 'https://example.com/existing.pdf',
size: 49 * 1024 * 1024,
size: 99 * 1024 * 1024,
},
];
const incomingFile = new File([new Uint8Array(2 * 1024 * 1024)], 'new.pdf');
expect(() =>
validateWorkflowFileSelection(currentFiles, [incomingFile]),
).toThrow('文件总大小不能超过 50.0 MB');
).toThrow('文件总大小不能超过 100.0 MB');
});
});

View File

@@ -21,8 +21,8 @@ export interface WorkflowResourceLike {
export const WORKFLOW_FILE_LIMITS = {
maxCount: 10,
maxSingleSize: 20 * 1024 * 1024,
maxTotalSize: 50 * 1024 * 1024,
maxSingleSize: 100 * 1024 * 1024,
maxTotalSize: 100 * 1024 * 1024,
} as const;
/**