perbaikan file path capture image saat presensi pegawai

This commit is contained in:
Salman Manoe 2021-09-08 11:33:42 +07:00
parent 7d0767e1d7
commit dad28b1d68

View File

@ -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<String, Object> map : data) {
Map<String, Object> 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;
}