diff options
| -rw-r--r-- | components/drm/drmUtils.ts | 1 | ||||
| -rw-r--r-- | lib/items/table/import-excel-button.tsx | 16 | ||||
| -rw-r--r-- | lib/pq/table/import-pq-button.tsx | 16 |
3 files changed, 29 insertions, 4 deletions
diff --git a/components/drm/drmUtils.ts b/components/drm/drmUtils.ts index c7b7ae5e..df58f0bd 100644 --- a/components/drm/drmUtils.ts +++ b/components/drm/drmUtils.ts @@ -50,6 +50,7 @@ export async function decryptWithServerAction(file: File): Promise<ArrayBuffer> fileName: file.name, fileSize: file.size, fileType: file.type, + remark: 'DTS 개발 서버라면 에러 발생이 정상입니다. (DRM 백엔드 없어서 CONNECTION_REJECTED 발생) 에러 발생시 원본 arrayBuffer를 그대로 리턴합니다.', error }); diff --git a/lib/items/table/import-excel-button.tsx b/lib/items/table/import-excel-button.tsx index 484fd778..845f5fe2 100644 --- a/lib/items/table/import-excel-button.tsx +++ b/lib/items/table/import-excel-button.tsx @@ -16,6 +16,7 @@ import { } from "@/components/ui/dialog" import { Progress } from "@/components/ui/progress" import { processFileImport } from "./import-item-handler" // 별도 파일로 분리 +import { decryptWithServerAction } from "@/components/drm/drmUtils" interface ImportItemButtonProps { onSuccess?: () => void @@ -55,8 +56,19 @@ export function ImportItemButton({ onSuccess }: ImportItemButtonProps) { setProgress(0) setError(null) - // 파일을 ArrayBuffer로 읽기 - const arrayBuffer = await file.arrayBuffer(); + // DRM 복호화 처리 - 서버 액션 직접 호출 + let arrayBuffer: ArrayBuffer; + try { + setProgress(10); + toast.info("파일 복호화 중..."); + arrayBuffer = await decryptWithServerAction(file); + setProgress(30); + } catch (decryptError) { + console.error("파일 복호화 실패, 원본 파일 사용:", decryptError); + toast.warning("파일 복호화에 실패하여 원본 파일을 사용합니다."); + // 복호화 실패 시 원본 파일 사용 + arrayBuffer = await file.arrayBuffer(); + } // ExcelJS 워크북 로드 const workbook = new ExcelJS.Workbook(); diff --git a/lib/pq/table/import-pq-button.tsx b/lib/pq/table/import-pq-button.tsx index e4e0147f..2fbf66d9 100644 --- a/lib/pq/table/import-pq-button.tsx +++ b/lib/pq/table/import-pq-button.tsx @@ -16,6 +16,7 @@ import { } from "@/components/ui/dialog" import { Progress } from "@/components/ui/progress" import { processFileImport } from "./import-pq-handler" // 별도 파일로 분리 +import { decryptWithServerAction } from "@/components/drm/drmUtils" interface ImportPqButtonProps { projectId?: number | null @@ -56,8 +57,19 @@ export function ImportPqButton({ projectId, onSuccess }: ImportPqButtonProps) { setProgress(0) setError(null) - // 파일을 ArrayBuffer로 읽기 - const arrayBuffer = await file.arrayBuffer(); + // DRM 복호화 처리 - 서버 액션 직접 호출 + let arrayBuffer: ArrayBuffer; + try { + setProgress(10); + toast.info("파일 복호화 중..."); + arrayBuffer = await decryptWithServerAction(file); + setProgress(30); + } catch (decryptError) { + console.error("파일 복호화 실패, 원본 파일 사용:", decryptError); + toast.warning("파일 복호화에 실패하여 원본 파일을 사용합니다."); + // 복호화 실패 시 원본 파일 사용 + arrayBuffer = await file.arrayBuffer(); + } // ExcelJS 워크북 로드 const workbook = new ExcelJS.Workbook(); |
