하석형 하석형 04-04
250404 하석형 파일 등록 및 수정 리눅스 -> 윈도우 경로로 수정
@1904bcae926116cf012b1cb977b2240c153fa6bd
src/main/java/com/takensoft/common/file/service/Impl/FileServiceImpl.java
--- src/main/java/com/takensoft/common/file/service/Impl/FileServiceImpl.java
+++ src/main/java/com/takensoft/common/file/service/Impl/FileServiceImpl.java
@@ -99,7 +99,16 @@
 
                 // 절대 경로 생성
                 String uploadPath = null;
-                uploadPath = locationPath + fileUploadPath;
+                // 1. 윈도우 환경
+                String[] pathArray = locationPath.split("/, ");
+                for (String path : pathArray) {
+                    if (path.startsWith("file:///")) {
+                        // "file:///" 부분을 제거하고 경로를 반환
+                        uploadPath = path.replace("file:///", "") + fileUploadPath;
+                    }
+                }
+                // 2. 리눅스 환경
+//                uploadPath = locationPath + fileUploadPath;
 
                 // 파일 정보 가공
                 String fileName = file.getOriginalFilename(); // 파일명 (원본)
@@ -158,7 +167,7 @@
     // 업로드 폴더(디렉터리) 생성
     private String makeDirectories(final String path) {
         File dir = new File(path);
-        if (dir.exists() == false) {
+        if (!dir.exists()) {
             dir.mkdirs();
         }
         return dir.getPath();
@@ -210,7 +219,16 @@
                 // http 부분
                 String url = frontUrl + ":" + serverPort;
                 String uploadPath = null;
-                uploadPath = locationPath + fileUploadPath;
+                // 1. 윈도우 환경
+                String[] pathArray = locationPath.split("/, ");
+                for (String path : pathArray) {
+                    if (path.startsWith("file:///")) {
+                        // "file:///" 부분을 제거하고 경로를 반환
+                        uploadPath = path.replace("file:///", "") + fileUploadPath;
+                    }
+                }
+                // 2. 리눅스 환경
+//                uploadPath = locationPath + fileUploadPath;
 
                 String path = file.get("absltPath").toString();
                 path = path.replace(url, uploadPath);
src/main/resources/application.yml
--- src/main/resources/application.yml
+++ src/main/resources/application.yml
@@ -43,8 +43,10 @@
       spec: maximumSize=100, expireAfterAccess=1h
   web:
     resources:
-      # static-locations: file:///C:/uploadFiles/, classpath:/static/
-      static-locations: /home/cloud-user/uploadFiles
+      # 윈도우 환경
+      static-locations: file:///C:/uploadFiles/, classpath:/static/
+      # 리눅스 환경
+#      static-locations: /home/cloud-user/uploadFiles
 
 # Mybatis settings
 #mybatis:
Add a comment
List