| | |
| | | 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; |
| | |
| | | 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; |
| | | |