feat: limit file name length

This commit is contained in:
Methapon2001 2023-11-30 14:43:41 +07:00
parent 751258e5b7
commit c3dfcfa1e7
No known key found for this signature in database
GPG key ID: 849924FEF46BD132
2 changed files with 16 additions and 0 deletions

View file

@ -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<void | { upload: string }> {
if (body.file && body.file.length > 85) {
throw new HttpError(HttpStatusCode.BAD_REQUEST, "ชื่อไฟล์ยาวเิกนกำหนด");
}
const basePath = `${cabinetName}/${drawerName}/${folderName}/`;
const pathname = `${basePath}${fileName}`;

View file

@ -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}`;