From c228a89c2834ee63b209bad608837c39643f350e Mon Sep 17 00:00:00 2001 From: dujinkim Date: Mon, 28 Jul 2025 11:44:16 +0000 Subject: (대표님) 의존성 docx 추가, basicContract API, gtc(계약일반조건), 벤더평가 esg 평가데이터 내보내기 개선, S-EDP 피드백 대응(CLS_ID, ITEM NO 등) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/api/upload/basicContract/chunk/route.ts | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) (limited to 'app/api/upload/basicContract') diff --git a/app/api/upload/basicContract/chunk/route.ts b/app/api/upload/basicContract/chunk/route.ts index e190fca4..383a8f36 100644 --- a/app/api/upload/basicContract/chunk/route.ts +++ b/app/api/upload/basicContract/chunk/route.ts @@ -1,7 +1,8 @@ import { NextRequest, NextResponse } from 'next/server'; import { mkdir, writeFile, appendFile, readFile, rm } from 'fs/promises'; import path from 'path'; -import { generateHashedFileName, saveBuffer } from '@/lib/file-stroage'; +import { generateHashedFileName, saveBuffer, saveDRMFile } from '@/lib/file-stroage'; +import { decryptWithServerAction } from '@/components/drm/drmUtils'; export async function POST(request: NextRequest) { try { @@ -48,16 +49,30 @@ export async function POST(request: NextRequest) { // 모든 청크를 하나의 Buffer로 병합 const mergedBuffer = Buffer.concat(chunks, totalSize); + + const mergedFile = new File([mergedBuffer], filename, { + type: chunk.type || 'application/octet-stream', + lastModified: Date.now(), + }); + + const saveResult = await saveDRMFile( + mergedFile, + decryptWithServerAction, // 복호화 함수 + 'basicContract/template', // 저장 디렉토리 + // userId // 선택 + ); + + console.log(`📄 병합 완료: ${filename} (총 ${totalSize} bytes)`); // 공용 함수를 사용하여 파일 저장 - const saveResult = await saveBuffer({ - buffer: mergedBuffer, - fileName: filename, - directory: 'basicContract/template', - originalName: filename - }); + // const saveResult = await saveBuffer({ + // buffer: mergedBuffer, + // fileName: filename, + // directory: 'basicContract/template', + // originalName: filename + // }); // 임시 파일 정리 (비동기로 처리) rm(tempDir, { recursive: true, force: true }) -- cgit v1.2.3