p_atflCd. 추가로직 정리

This commit is contained in:
2025-04-01 17:04:47 +09:00
parent 26854a8610
commit 84caaa3977
3 changed files with 22 additions and 2 deletions
+1
View File
@@ -17,3 +17,4 @@ dist
# env
.env*
.qodo
+1 -1
View File
@@ -1,2 +1,2 @@
NEXT_PUBLIC_PORT=3000
NEXT_PUBLIC_SERVER_API_URL=http://192.168.0.102:8000
NEXT_PUBLIC_SERVER_API_URL=http://localhost:8000
+20 -1
View File
@@ -11,8 +11,12 @@ function ImagePage() {
const file = e.target.files?.item(0);
if (!file) return;
//const p_atflCd = store.getState().upload.atflCd; // Redux 스토어에서 atflCd 가져오기
const upload = new Upload(file, {
endpoint: `${ENDPOINT.ATTACH_SERVICE.TUS_UPLOAD}`,
chunkSize: 10 * 1024 * 1024, // 5MB chunk size
headers: {
[CLAIM_NAME]: getCookie(CLAIM_NAME) ?? "",
[AUTH_USER_ID]: getCookie(AUTH_USER_ID) ?? "",
@@ -20,7 +24,8 @@ function ImagePage() {
retryDelays: [0, 3000, 5000, 10000, 20000],
metadata: {
filename: file.name,
filetype: file.type,
filetype: file.type
// atflCd: p_atflCd,
},
onError: function (error) {
console.log("Failed because: " + error);
@@ -35,6 +40,20 @@ function ImagePage() {
(upload.file as File).name,
upload.url,
);
console.log("upload._req:", upload._req);
if(upload._req){
const xhr = upload._req._xhr; // 업로드에 사용된 XMLHttpRequest 객체
const xFileInfo = xhr.getResponseHeader('X-file-info'); // X-file-info 헤더 가져오기
if (xFileInfo) {
const fileInfo = JSON.parse(xFileInfo);
console.log('fileInfo :', fileInfo);
const downloadUrl = `${ENDPOINT.ATTACH_SERVICE.TUS_DOWNLOAD}/${fileInfo.atflId}`;
console.log('Download URL:', downloadUrl);
// store.dispatch(setAtflCd(fileInfo.atflCd)); // atflCd 저장
}
}
},
});