diff --git a/src/controllers/FileController.ts b/src/controllers/FileController.ts index 0a1dd32..1dffbe5 100644 --- a/src/controllers/FileController.ts +++ b/src/controllers/FileController.ts @@ -211,6 +211,9 @@ export class FileController extends Controller { let fileList = !body.replace ? await Promise.all( body.fileList.map(async ({ fileName, ...props }) => { + if(fileName.length > 85){ + throw new Error("ไม่สามารถอัปโหลดไฟล์ได้ เนื่องจากชื่อไฟล์มีความยาวเกินที่ระบบกำหนด กรุณาปรับชื่อไฟล์ให้สั้นลง"); + } const dotIndex = fileName.lastIndexOf("."); const originalName = dotIndex !== -1 && !fileName.startsWith(".") ? fileName.slice(0, dotIndex) : fileName; diff --git a/src/controllers/StorageController.ts b/src/controllers/StorageController.ts index 68b07b5..73656ee 100644 --- a/src/controllers/StorageController.ts +++ b/src/controllers/StorageController.ts @@ -180,9 +180,6 @@ 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;