From edb424916120bb776ddc6d833a0a04e6af187804 Mon Sep 17 00:00:00 2001 From: Seokyung Lim Date: Tue, 21 Nov 2023 17:45:01 +0900 Subject: [PATCH] =?UTF-8?q?chore=20:=20=EC=9D=8C=EC=95=85=20=EC=A0=9C?= =?UTF-8?q?=EB=AA=A9=20=EA=B8=B8=EC=9D=B4=20=EC=A0=9C=ED=95=9C=20=EC=B6=94?= =?UTF-8?q?=EA=B0=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/upload/upload.service.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/server/src/upload/upload.service.ts b/server/src/upload/upload.service.ts index cadd443..3d250a0 100644 --- a/server/src/upload/upload.service.ts +++ b/server/src/upload/upload.service.ts @@ -12,10 +12,11 @@ export class UploadService { this.objectStorage = nCloudConfigService.createObjectStorageOption(); } - private isValidPath(path: string) { + private isValidPath(path: string, fileName: string) { for (let i = 0; i < pathPattern.length; i++) { if (pathPattern[i].test(path)) { - return true; + if (i < 2) return true; + if (i == 2 && fileName.length <= 50) return true; } } @@ -34,7 +35,7 @@ export class UploadService { ext: string, ): Promise { try { - if (!this.isValidPath(keyPath) || !this.isValidExt(ext)) + if (!this.isValidPath(keyPath, fileName) || !this.isValidExt(ext)) throw new HttpException('BAD REQUEST', HTTP_STATUS_CODE.BAD_REQUEST); const url = await this.objectStorage.getSignedUrlPromise('putObject', {