From 5fb1952ae91f1a739803247266e87dbd15ea1f27 Mon Sep 17 00:00:00 2001
From: 이민희 <mhlee@maprex.co.kr>
Date: 수, 01 12월 2021 13:23:09 +0900
Subject: [PATCH] 충돌 수정

---
 src/main/java/kr/wisestone/owl/util/CommonUtil.java |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/src/main/java/kr/wisestone/owl/util/CommonUtil.java b/src/main/java/kr/wisestone/owl/util/CommonUtil.java
index fb52889..5659bfd 100644
--- a/src/main/java/kr/wisestone/owl/util/CommonUtil.java
+++ b/src/main/java/kr/wisestone/owl/util/CommonUtil.java
@@ -344,6 +344,24 @@
         return fileMap;
     }
 
+    //  string file �젙蹂대�� file Map �삎�깭濡� 蹂�寃쏀븳�떎.
+    public static Map<String, Object> makeFileMap(String fileName, String file, String contentType) {
+        Map<String, Object> fileMap = new HashMap<>();
+
+        try {
+            byte[] bytes = Base64.decodeBase64(file);
+
+            fileMap.put("fileName", fileName);
+            fileMap.put("fileSize", bytes.length);
+            fileMap.put("contentType", contentType);
+            fileMap.put("file", CommonUtil.bytesToFile(fileName, bytes));
+        } catch (Exception e) {
+            LOGGER.debug(e.getMessage());
+        }
+
+        return fileMap;
+    }
+
     public static String getPostDataString(Map<String, String> params) throws UnsupportedEncodingException {
         StringBuilder result = new StringBuilder();
         boolean first = true;
@@ -378,6 +396,42 @@
         return convertFile;
     }
 
+    // string�쓣 �뙆�씪濡� 蹂��솚
+    public static File stringToFile(String fileName, String file) {
+
+        byte[] bytes = null;
+        try {
+            bytes = Base64.decodeBase64(file);
+
+        } catch (Exception ex) {
+            LOGGER.debug("string to bytes 蹂��솚 �삤瑜�");
+        }
+
+        if (bytes != null) {
+            return bytesToFile(fileName, bytes);
+        }
+        return  null;
+    }
+
+    // bytes瑜� �뙆�씪濡� 蹂��솚
+    public static File bytesToFile(String fileName, byte[] bytes) {
+        File convertFile = new File(WebAppUtil.getContextRealPath() + TMP_UPLOAD_FOLDER + getFileNameByUUID(fileName));
+        if (!convertFile.exists()) {
+            convertFile.mkdirs();
+        }
+
+        try{
+            FileOutputStream lFileOutputStream = new FileOutputStream(convertFile);
+            lFileOutputStream.write(bytes);
+            lFileOutputStream.close();
+
+        }catch (IllegalStateException | IOException e) {
+            LOGGER.debug("bytes �뙆�씪 file 蹂��솚 �삤瑜�");
+        }
+
+        return convertFile;
+    }
+
     public static InputStream getFileInputStream(String strPath, String strNewFileName){
         InputStream objInputStream = null;
 

--
Gitblit v1.8.0