diff options
| author | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-14 05:28:01 +0000 |
|---|---|---|
| committer | dujinkim <dujin.kim@dtsolution.co.kr> | 2025-09-14 05:28:01 +0000 |
| commit | 675b4e3d8ffcb57a041db285417d81e61284d900 (patch) | |
| tree | 254f3d6a6c0ce39ae8fba35618f3810e08945f19 /app/api/contracts/get-template/route.ts | |
| parent | 39f12cb19f29cbc5568057e154e6adf4789ae736 (diff) | |
(대표님) RFQ-last, tbe-last, 기본계약 템플릿 내 견적,입찰,계약 추가, env.dev NAS_PATH 수정
Diffstat (limited to 'app/api/contracts/get-template/route.ts')
| -rw-r--r-- | app/api/contracts/get-template/route.ts | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/app/api/contracts/get-template/route.ts b/app/api/contracts/get-template/route.ts new file mode 100644 index 00000000..c987c527 --- /dev/null +++ b/app/api/contracts/get-template/route.ts @@ -0,0 +1,33 @@ +import { NextRequest, NextResponse } from "next/server"; +import { readFile } from "fs/promises"; +import path from "path"; + +export async function POST(request: NextRequest) { + try { + const { templatePath } = await request.json(); + + if (!templatePath) { + return NextResponse.json( + { error: "템플릿 경로가 필요합니다." }, + { status: 400 } + ); + } + + const fullPath = path.join(process.cwd(), `${process.env.NAS_PATH}`, templatePath); + const fileBuffer = await readFile(fullPath); + + return new NextResponse(fileBuffer, { + headers: { + 'Content-Type': 'application/vnd.openxmlformats-officedocument.wordprocessingml.document', + 'Content-Disposition': `attachment; filename="template.docx"` + } + }); + + } catch (error) { + console.error("템플릿 파일 읽기 실패:", error); + return NextResponse.json( + { error: "템플릿 파일을 읽을 수 없습니다." }, + { status: 500 } + ); + } +}
\ No newline at end of file |
