From c87ae27070b05f68e1b1f87d206707fc887c56f9 Mon Sep 17 00:00:00 2001 From: AdisakKanthawilang Date: Thu, 6 Feb 2025 11:23:21 +0700 Subject: [PATCH] fix delete file s3 --- src/controllers/FileController.ts | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/controllers/FileController.ts b/src/controllers/FileController.ts index 3e70545..4e1b501 100644 --- a/src/controllers/FileController.ts +++ b/src/controllers/FileController.ts @@ -695,7 +695,22 @@ export class SubFileController extends Controller { @Path() subId: string, @Path() file: string, ) { - const result = await deleteFile([name, group, id, subId], file); + if (name !== "ระบบประเมิน") { + const rawPath = [ + name, + group, + id, + file + ]; + const fullPath = rawPath + .filter((path) => path !== undefined && path !== null) + .join("/"); + + const path = fullPath; + return await s3DeleteFile(path); + } + + const result = await deleteFile([name, group, id, subId], file); if (!result) { throw new Error("เกิดข้อผิดพลาดกับระบบจัดการไฟล์ ไม่สามารถลบไฟล์ ได้");