diff --git a/Services/server/src/controllers/fileController.ts b/Services/server/src/controllers/fileController.ts index af3d0b3..5cc2089 100644 --- a/Services/server/src/controllers/fileController.ts +++ b/Services/server/src/controllers/fileController.ts @@ -84,6 +84,10 @@ export class FileController extends Controller { @Path() drawerName: string, @Path() folderName: string, ) { + if (body.file.length > 85) { + throw new HttpError(HttpStatusCode.BAD_REQUEST, "ชื่อไฟล์ยาวเิกนกำหนด"); + } + const basePath = `${cabinetName}/${drawerName}/${folderName}/`; const pathname = `${basePath}${body.file}`; @@ -167,6 +171,10 @@ export class FileController extends Controller { keyword?: string; }, ): Promise { + if (body.file && body.file.length > 85) { + throw new HttpError(HttpStatusCode.BAD_REQUEST, "ชื่อไฟล์ยาวเิกนกำหนด"); + } + const basePath = `${cabinetName}/${drawerName}/${folderName}/`; const pathname = `${basePath}${fileName}`; diff --git a/Services/server/src/controllers/subFolderFileController.ts b/Services/server/src/controllers/subFolderFileController.ts index d2371ba..3c99af6 100644 --- a/Services/server/src/controllers/subFolderFileController.ts +++ b/Services/server/src/controllers/subFolderFileController.ts @@ -88,6 +88,10 @@ export class SubFolderFileController extends Controller { @Path() folderName: string, @Path() subFolderName: string, ) { + if (body.file && body.file.length > 85) { + throw new HttpError(HttpStatusCode.BAD_REQUEST, "ชื่อไฟล์ยาวเิกนกำหนด"); + } + const basePath = `${cabinetName}/${drawerName}/${folderName}/${subFolderName}/`; const pathname = `${basePath}${body.file}`; @@ -171,6 +175,10 @@ export class SubFolderFileController extends Controller { keyword?: string; }, ) { + if (body.file && body.file.length > 85) { + throw new HttpError(HttpStatusCode.BAD_REQUEST, "ชื่อไฟล์ยาวเิกนกำหนด"); + } + const basePath = `${cabinetName}/${drawerName}/${folderName}/${subFolderName}/`; const pathname = `${basePath}${fileName}`;