
--- 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 @@ |
99 | 99 |
|
100 | 100 |
// 절대 경로 생성 |
101 | 101 |
String uploadPath = null; |
102 |
- uploadPath = locationPath + fileUploadPath; |
|
102 |
+ // 1. 윈도우 환경 |
|
103 |
+ String[] pathArray = locationPath.split("/, "); |
|
104 |
+ for (String path : pathArray) { |
|
105 |
+ if (path.startsWith("file:///")) { |
|
106 |
+ // "file:///" 부분을 제거하고 경로를 반환 |
|
107 |
+ uploadPath = path.replace("file:///", "") + fileUploadPath; |
|
108 |
+ } |
|
109 |
+ } |
|
110 |
+ // 2. 리눅스 환경 |
|
111 |
+// uploadPath = locationPath + fileUploadPath; |
|
103 | 112 |
|
104 | 113 |
// 파일 정보 가공 |
105 | 114 |
String fileName = file.getOriginalFilename(); // 파일명 (원본) |
... | ... | @@ -158,7 +167,7 @@ |
158 | 167 |
// 업로드 폴더(디렉터리) 생성 |
159 | 168 |
private String makeDirectories(final String path) { |
160 | 169 |
File dir = new File(path); |
161 |
- if (dir.exists() == false) { |
|
170 |
+ if (!dir.exists()) { |
|
162 | 171 |
dir.mkdirs(); |
163 | 172 |
} |
164 | 173 |
return dir.getPath(); |
... | ... | @@ -210,7 +219,16 @@ |
210 | 219 |
// http 부분 |
211 | 220 |
String url = frontUrl + ":" + serverPort; |
212 | 221 |
String uploadPath = null; |
213 |
- uploadPath = locationPath + fileUploadPath; |
|
222 |
+ // 1. 윈도우 환경 |
|
223 |
+ String[] pathArray = locationPath.split("/, "); |
|
224 |
+ for (String path : pathArray) { |
|
225 |
+ if (path.startsWith("file:///")) { |
|
226 |
+ // "file:///" 부분을 제거하고 경로를 반환 |
|
227 |
+ uploadPath = path.replace("file:///", "") + fileUploadPath; |
|
228 |
+ } |
|
229 |
+ } |
|
230 |
+ // 2. 리눅스 환경 |
|
231 |
+// uploadPath = locationPath + fileUploadPath; |
|
214 | 232 |
|
215 | 233 |
String path = file.get("absltPath").toString(); |
216 | 234 |
path = path.replace(url, uploadPath); |
--- src/main/resources/application.yml
+++ src/main/resources/application.yml
... | ... | @@ -43,8 +43,10 @@ |
43 | 43 |
spec: maximumSize=100, expireAfterAccess=1h |
44 | 44 |
web: |
45 | 45 |
resources: |
46 |
- # static-locations: file:///C:/uploadFiles/, classpath:/static/ |
|
47 |
- static-locations: /home/cloud-user/uploadFiles |
|
46 |
+ # 윈도우 환경 |
|
47 |
+ static-locations: file:///C:/uploadFiles/, classpath:/static/ |
|
48 |
+ # 리눅스 환경 |
|
49 |
+# static-locations: /home/cloud-user/uploadFiles |
|
48 | 50 |
|
49 | 51 |
# Mybatis settings |
50 | 52 |
#mybatis: |
Add a comment
Delete comment
Once you delete this comment, you won't be able to recover it. Are you sure you want to delete this comment?