diff --git a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/AbsensiPegawaiServiceImpl.java b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/AbsensiPegawaiServiceImpl.java index 113d7135..f8375943 100644 --- a/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/AbsensiPegawaiServiceImpl.java +++ b/jasamedika-business/src/main/java/com/jasamedika/medifirst2000/service/impl/AbsensiPegawaiServiceImpl.java @@ -159,35 +159,17 @@ public class AbsensiPegawaiServiceImpl extends BaseVoServiceImpl implements Abse public String getDirPath(String dirname) { String result = ""; - String your_os = System.getProperty("os.name").toLowerCase(); - if (your_os.indexOf("win") >= 0) { - // if_windows - result = dirname + "\\"; - } else if (your_os.indexOf("nix") >= 0 || your_os.indexOf("nux") >= 0 || your_os.indexOf("mac") >= 0) { - // if_unix_or_mac - result = dirname + "//"; - } else { - // unknown_os? - result = dirname + "/"; - } - - return result; - } - - public String getImageAbsoluteFilePath(String filename) { - String result = ""; - String workingDir = System.getProperty("user.dir"); String your_os = System.getProperty("os.name").toLowerCase(); if (your_os.indexOf("win") >= 0) { // if_windows - result = workingDir + "\\" + filename; + result = workingDir + "\\" + presensiCapturePath + "\\" + dirname + "\\"; } else if (your_os.indexOf("nix") >= 0 || your_os.indexOf("nux") >= 0 || your_os.indexOf("mac") >= 0) { // if_unix_or_mac - result = workingDir + presensiCapturePath + filename; + result = workingDir + "//" + presensiCapturePath + "//" + dirname + "//"; } else { // unknown_os? - result = workingDir + "/" + filename; + result = workingDir + "/" + presensiCapturePath + "/" + dirname + "/"; } return result; @@ -209,10 +191,10 @@ public class AbsensiPegawaiServiceImpl extends BaseVoServiceImpl implements Abse File dire = new File(directory); if (!dire.exists()) { - dire.mkdir(); + dire.mkdirs(); } - File file = new File(getImageAbsoluteFilePath(filename)); + File file = new File(filename); ImageIO.write(bufferedImage, "jpg", file); } catch (IOException e) { e.printStackTrace(); @@ -286,8 +268,8 @@ public class AbsensiPegawaiServiceImpl extends BaseVoServiceImpl implements Abse for (Map map : data) { Map mapRs = new HashMap<>(); String imageURLData = ""; - String encodeRs = encodeFileToBase64Binary(new File(getImageAbsoluteFilePath( - getDirPath(map.get("trdate").toString()) + map.get("filePath").toString()))); + String encodeRs = encodeFileToBase64Binary( + new File(getDirPath(map.get("trdate").toString()) + map.get("filePath").toString())); if (CommonUtil.isNotNullOrEmpty(encodeRs)) { imageURLData = "data:image/jpg;base64," + encodeRs; }