From 4252efe8ada73a8c60643f9b2275d005d3de5aff Mon Sep 17 00:00:00 2001 From: Adisak Date: Fri, 31 Oct 2025 18:32:54 +0700 Subject: [PATCH] fix to thorw --- src/controllers/StorageController.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/controllers/StorageController.ts b/src/controllers/StorageController.ts index 006900c..68b07b5 100644 --- a/src/controllers/StorageController.ts +++ b/src/controllers/StorageController.ts @@ -180,14 +180,14 @@ export class DocumentController extends Controller { let fileList = !body.replace ? body.fileList.map(({ fileName, ...props }) => { + if(fileName.length > 85){ + throw new Error("ไม่สามารถอัปโหลดไฟล์ได้ เนื่องจากชื่อไฟล์มีความยาวเกินที่ระบบกำหนด กรุณาปรับชื่อไฟล์ให้สั้นลง"); + } const dotIndex = fileName.lastIndexOf("."); let originalName = dotIndex !== -1 && !fileName.startsWith(".") ? fileName.slice(0, dotIndex) : fileName; const extension = dotIndex !== -1 && !fileName.startsWith(".") ? fileName.slice(dotIndex) : ""; - if([...originalName].length > 95){ - originalName = [...originalName].slice(0, 95).join(''); - } let i = 1; while (list.findIndex((v) => v.fileName === fileName) !== -1 || used.includes(fileName)) { fileName = `${originalName} (${i++})`;