From 1600a79b5bf47eeffe9a61cb801a4c8095ebc01e Mon Sep 17 00:00:00 2001 From: leebj Date: Mon, 24 Jun 2024 09:31:56 +0900 Subject: [PATCH 1/2] =?UTF-8?q?=EB=B6=88=ED=95=84=EC=9A=94=ED=95=9C=20?= =?UTF-8?q?=EC=86=8C=EC=8A=A4=20=EC=82=AD=EC=A0=9C(=ED=8C=8C=EC=9D=BC=20?= =?UTF-8?q?=EB=A1=9C=EB=93=9C=20URL=20=EB=B3=80=EA=B2=BD)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp index 146e802..f61e709 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp @@ -477,13 +477,8 @@ if($P.fileInfos.length > 0){ let promiseArr = []; - // URL에 c: d: 제거 - $P.fileInfos.forEach(f => { - // FIXME: URL에 c: d: 제거 ??? - f.URL = f.URL.replace(/c:/g, ""); - f.URL = f.URL.replace(/d:/g, ""); - promiseArr.push(fnCreateFileFromFileInfo(f)); - }); + + $P.fileInfos.forEach(f => { promiseArr.push(fnCreateFileFromFileInfo(f)); }); Promise.all(promiseArr).then((values) => { $P.fileArr = $P.fileArr.concat(values); From 70caae4e9e11509249afdbb529e7914902a92da4 Mon Sep 17 00:00:00 2001 From: "Jonguk. Lim" Date: Mon, 24 Jun 2024 09:42:06 +0900 Subject: [PATCH 2/2] fix: file download fix --- .../jsp/adds/nims/dsuseMgtRslt-info.jsp | 14 ++++-- .../resources/js/adds/cmmn/adds-cmmnUtil.js | 48 +++++-------------- 2 files changed, 24 insertions(+), 38 deletions(-) diff --git a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp index 146e802..e9f27ec 100644 --- a/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp +++ b/src/main/webapp/WEB-INF/jsp/adds/nims/dsuseMgtRslt-info.jsp @@ -480,9 +480,17 @@ // URL에 c: d: 제거 $P.fileInfos.forEach(f => { // FIXME: URL에 c: d: 제거 ??? - f.URL = f.URL.replace(/c:/g, ""); - f.URL = f.URL.replace(/d:/g, ""); - promiseArr.push(fnCreateFileFromFileInfo(f)); + // if(f.URL){ + // f.URL = f.URL.toLowerCase().replace(/c:/g, ""); + // f.URL = f.URL.toLowerCase().replace(/d:/g, ""); + // } + try{ + fnCreateFileFromFileInfo(f) + promiseArr.push(fnCreateFileFromFileInfo(f)); + }catch(e){ + console.log(e); + } + //promiseArr.push(fnCreateFileFromFileInfo(f)); }); Promise.all(promiseArr).then((values) => { diff --git a/src/main/webapp/resources/js/adds/cmmn/adds-cmmnUtil.js b/src/main/webapp/resources/js/adds/cmmn/adds-cmmnUtil.js index e6197e8..321d543 100644 --- a/src/main/webapp/resources/js/adds/cmmn/adds-cmmnUtil.js +++ b/src/main/webapp/resources/js/adds/cmmn/adds-cmmnUtil.js @@ -1,38 +1,16 @@ /************************************************************************** - * 서버의 파일 정보로 javascript File 객체 생성 - **************************************************************************/ -async function fnCreateFileFromFileInfo(fileInfo) { +* 서버의 파일 정보로 javascript File 객체 생성 +**************************************************************************/ +async function fnCreateFileFromFileInfo(fileInfo){ - try { - let response = await fetch(fileInfo.URL); + let response = await fetch(fileInfo.URL); + let data = await response.blob(); + let metadata = { + type: fileInfo.MIME_TYPE + }; + let file = new File([data], fileInfo.FILE_NM, metadata); + file.id = fileInfo.FILE_ID; + file.url = fileInfo.URL; - if (!response.ok) { - //throw new Error(`HTTP error! status: ${response.status}`); - let file = new File([], fileInfo.FILE_NM, metadata); - file.id = fileInfo.FILE_ID; - file.url = fileInfo.URL; - return new Promise(resolve => { - resolve(file); - }); - } - - let data = await response.blob(); - - let metadata = { - type: fileInfo.MIME_TYPE - }; - let file = new File([data], fileInfo.FILE_NM, metadata); - file.id = fileInfo.FILE_ID; - file.url = fileInfo.URL; - - return new Promise(resolve => { - resolve(file); - }); - } catch (error) { - console.error('Fetch error:', error); - - // Handle the error appropriately, e.g., return a default value or rethrow - // Here, we'll return null to indicate failure - return null; - } -} + return new Promise(resolve => { resolve(file); }); +} \ No newline at end of file