diff options
Diffstat (limited to 'app/api/dolce/upload-files/route.ts')
| -rw-r--r-- | app/api/dolce/upload-files/route.ts | 24 |
1 files changed, 19 insertions, 5 deletions
diff --git a/app/api/dolce/upload-files/route.ts b/app/api/dolce/upload-files/route.ts index 898f9b2a..3d0a92f7 100644 --- a/app/api/dolce/upload-files/route.ts +++ b/app/api/dolce/upload-files/route.ts @@ -81,19 +81,33 @@ async function uploadFileToDolce( async function getExistingFileSeq(uploadId: string): Promise<number> { try { const response = await fetch( - `${DOLCE_API_URL}/PorjectWebProxyService.ashx?service=FileInfoList`, + `${DOLCE_API_URL}/Services/VDCSWebService.svc/FileInfoList`, { method: "POST", headers: { "Content-Type": "application/json" }, - body: JSON.stringify({ uploadId }), + body: JSON.stringify({ uploadId: uploadId }), } ); if (response.ok) { const data = await response.json(); - const existingCount = data.FileInfoListResult?.length || 0; - console.log(`[Proxy] 기존 파일=${existingCount}개, 새 파일 시작 Seq=${existingCount + 1}`); - return existingCount + 1; + + let maxSeq = 0; + + // FileInfoListResult가 배열인지 확인하고 최대 FileSeq 탐색 + if (data.FileInfoListResult && Array.isArray(data.FileInfoListResult)) { + data.FileInfoListResult.forEach((item: any) => { + // FileSeq가 문자열로 오므로 숫자로 변환 (예: "6") + const seq = parseInt(item.FileSeq, 10); + if (!isNaN(seq) && seq > maxSeq) { + maxSeq = seq; + } + }); + } + + const nextSeq = maxSeq + 1; + console.log(`[Proxy] 기존 파일 최대 Seq=${maxSeq}, 새 파일 시작 Seq=${nextSeq}`); + return nextSeq; } else { console.warn(`[Proxy] FileInfoList 조회 실패, startSeq=1로 시작`); return 1; |
