대용량 다운로드 테스트 html 추가

This commit is contained in:
2026-02-11 12:01:18 +09:00
parent 5d33190c31
commit 89504e4156
2 changed files with 64 additions and 0 deletions

View File

@@ -98,6 +98,7 @@ public class SecurityConfig {
"/api/members/*/password",
"/v3/api-docs/**",
"/chunk_upload_test.html",
"/download_progress_test.html",
"/api/model/file-chunk-upload",
"/api/upload/file-chunk-upload",
"/api/upload/chunk-upload-complete",

View File

@@ -0,0 +1,63 @@
<!doctype html>
<html lang="ko">
<head>
<meta charset="utf-8" />
<title>라벨 ZIP 다운로드</title>
</head>
<body>
<h3>라벨 ZIP 다운로드</h3>
UUID:
<input id="uuid" value="6d8d49dc-0c9d-4124-adc7-b9ca610cc394" />
<button onclick="download()">다운로드</button>
<br><br>
<progress id="bar" value="0" max="100" style="width:400px;"></progress>
<div id="status"></div>
<script>
async function download() {
const uuid = document.getElementById("uuid").value.trim();
const url = `/api/training-data/stage/download/${uuid}`;
const res = await fetch(url, {
headers: {
"Authorization": `Bearer eyJhbGciOiJIUzM4NCJ9.eyJzdWIiOiJmYzUwNDYxZC0wOGYwLTRhYjYtOTg4MC03ZmJmYzM2ZjNmOGIiLCJpYXQiOjE3NzA3Nzg3ODIsImV4cCI6MTc3MDg2NTE4Mn0.4OOF4r2lxymr8UwpqRW_qLecE8IpwNOFJHXSsZX6d6Yuk2fT7NcYPS5LenFRli3N`,
"kamco-download-uuid": uuid
}
});
if (!res.ok) {
document.getElementById("status").innerText =
"실패: " + res.status;
return;
}
const total = parseInt(res.headers.get("Content-Length") || "0", 10);
const reader = res.body.getReader();
const chunks = [];
let received = 0;
while (true) {
const { done, value } = await reader.read();
if (done) break;
chunks.push(value);
received += value.length;
if (total) {
document.getElementById("bar").value =
(received / total) * 100;
}
}
const blob = new Blob(chunks);
const a = document.createElement("a");
a.href = URL.createObjectURL(blob);
a.download = uuid + ".zip";
a.click();
document.getElementById("status").innerText = "완료 ✅";
}
</script>
</body>
</html>