feat: limit file name length
This commit is contained in:
parent
751258e5b7
commit
c3dfcfa1e7
2 changed files with 16 additions and 0 deletions
|
|
@ -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}`;
|
||||
|
||||
|
|
|
|||
|
|
@ -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}`;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue