diff --git a/apps/sn/app/components/lib/utils/fileUploadUtil.tsx b/apps/sn/app/components/lib/utils/fileUploadUtil.tsx index c2d380b54..9b3721cd0 100644 --- a/apps/sn/app/components/lib/utils/fileUploadUtil.tsx +++ b/apps/sn/app/components/lib/utils/fileUploadUtil.tsx @@ -51,4 +51,6 @@ export const handleUpload = (files: FileList, options?: UploadOptions) => { upload.start(); options?.handleUploadStart?.(upload); + + console.log("upload start"); }; diff --git a/apps/sn/app/components/ui/fileUploadForm.tsx b/apps/sn/app/components/ui/fileUploadForm.tsx index f00689a3b..736d8b4be 100644 --- a/apps/sn/app/components/ui/fileUploadForm.tsx +++ b/apps/sn/app/components/ui/fileUploadForm.tsx @@ -7,6 +7,16 @@ import { FileUploader } from "@common/components"; import { handleUpload } from "@utils"; const FileUploadForm = ({ title, onSubmit }: { title: string, onSubmit:(files:FileList, year:string, quarter:string) => void }) => { + + const handleUploadResponse = (file: File) => async (res: HttpResponse) => { + const fileInfo = res.getHeader("X-File-Info"); + if (!fileInfo) return; + + const { atflCd, atflId } = JSON.parse(fileInfo) ?? {}; + const orgnlFileNm = file.name; + + console.log(atflCd, atflId, orgnlFileNm); + }; // 현재 년도부터 10년 전까지의 년도 옵션 생성 const yearOptions = Array.from({ length: 10 }, (_, i) => { @@ -17,6 +27,8 @@ const FileUploadForm = ({ title, onSubmit }: { title: string, onSubmit:(files:Fi const [files, setFiles] = useState(null); const [selectedYear, setSelectedYear] = useState(yearOptions[0]?.val || ''); const [selectedQuarter, setSelectedQuarter] = useState(quater[0]?.val || ''); + const [upload, setUpload] = useState(null); + return (
@@ -49,7 +61,9 @@ const FileUploadForm = ({ title, onSubmit }: { title: string, onSubmit:(files:Fi if (!selectedFiles) return; const fileArray = Array.from(selectedFiles); - setFiles(fileArray); + if(!fileArray){ + setFiles(fileArray); + } if (fileArray[0]) { handleUpload(selectedFiles, { handleUploadStart: setUpload, @@ -57,6 +71,7 @@ const FileUploadForm = ({ title, onSubmit }: { title: string, onSubmit:(files:Fi handleResponse: handleUploadResponse(fileArray[0]), }); } + }} customPreview={<>} /> diff --git a/apps/sn/app/oper/floodPre/page.tsx b/apps/sn/app/oper/floodPre/page.tsx index 84ccfa743..bbedde0a3 100644 --- a/apps/sn/app/oper/floodPre/page.tsx +++ b/apps/sn/app/oper/floodPre/page.tsx @@ -26,7 +26,7 @@ const Page = () => { alert('파일을 선택해주세요') } // TODO: 추후 파일코드 동적으로 세팅 - handleDownload('/sn/attach-service/api/v1/download/6066b08c-2a55-438c-b8ff-2aed9739a0c6', fileNm) + handleDownload('/attach-service/api/v1/download/6066b08c-2a55-438c-b8ff-2aed9739a0c6', fileNm) } //TODO: 파일 업로드 처리 return (