From 55264117d760fa7278094ee6b137c187f1ac660b Mon Sep 17 00:00:00 2001 From: dujinkim Date: Tue, 13 May 2025 04:09:32 +0000 Subject: (김준회) 복호화 유틸함수 추가, rfq 파일업로드시 복호화 유틸함수 사용 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- lib/rfqs/service.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'lib') diff --git a/lib/rfqs/service.ts b/lib/rfqs/service.ts index c7d1c3cd..820de294 100644 --- a/lib/rfqs/service.ts +++ b/lib/rfqs/service.ts @@ -27,6 +27,8 @@ import * as z from "zod" import { users } from "@/db/schema/users"; import { headers } from 'next/headers'; +// DRM 복호화 관련 유틸 import +import { decryptWithServerAction } from "@/components/drm/drmUtils"; interface InviteVendorsInput { rfqId: number @@ -468,9 +470,13 @@ export async function processRfqAttachments(args: { await fs.mkdir(rfqDir, { recursive: true }); for (const file of newFiles) { - // 2-1) File -> Buffer - const ab = await file.arrayBuffer(); - const buffer = Buffer.from(ab); + // 2-1) DRM 복호화 시도 ---------------------------------------------------------------------- + // decryptWithServerAction 함수는 오류 처리 및 원본 반환 로직을 포함하고 있음 (해제 실패시 원본 반환) + // 이후 코드가 buffer로 작업하므로 buffer로 전환한다. + const decryptedData = await decryptWithServerAction(file); + const buffer = Buffer.from(decryptedData); + // ----------------------------------------------------------------------------------------- + // 2-2) 고유 파일명 const uniqueName = `${randomUUID()}-${file.name}`; -- cgit v1.2.3