fix: mongodb file oversize (#4594)

This commit is contained in:
Archer
2025-04-18 15:01:18 +08:00
committed by GitHub
parent a18d34e40a
commit d9a4a5f3e7
4 changed files with 82 additions and 52 deletions

View File

@@ -65,9 +65,10 @@ export async function uploadFile({
const bucket = getGridBucket(bucketName);
const fileSize = stats.size;
// 单块大小:尽可能大,但不超过 14MB不小于512KB
const chunkSizeBytes = (() => {
// 计算理想块大小:文件大小 ÷ 目标块数(10)
const idealChunkSize = Math.ceil(fileSize / 10);
// 计算理想块大小:文件大小 ÷ 目标块数(10)。 并且每个块需要小于 14MB
const idealChunkSize = Math.min(Math.ceil(fileSize / 10), 14 * 1024 * 1024);
// 确保块大小至少为512KB
const minChunkSize = 512 * 1024; // 512KB