Fix: contribution branch 반영
This commit is contained in:
@@ -150,7 +150,12 @@ public class AttachmentService extends AbstractService {
|
||||
*/
|
||||
@Transactional(readOnly = true)
|
||||
public AttachmentImageResponseDto loadImage(String imagename) {
|
||||
return storageUtils.loadImage(imagename.replaceAll(EDITOR_FILE_SEPARATOR, FILE_SEPARATOR));
|
||||
if(FILE_SEPARATOR.equals("\\")) {//윈도우기반 자바시스템일 때 하이픈 character to be escaped is missing 에러방지
|
||||
imagename = imagename.replaceAll(EDITOR_FILE_SEPARATOR, "\\\\"); //getFileSystem().getPath에서 디스크의 경로를 사용할 때
|
||||
} else { //리눅스 또는 맥 기반 자바시스템 경로일 때(아래)
|
||||
imagename = imagename.replaceAll(EDITOR_FILE_SEPARATOR, FILE_SEPARATOR);
|
||||
}
|
||||
return storageUtils.loadImage(imagename);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -51,10 +51,16 @@ public class FileStorageUtils implements StorageUtils {
|
||||
private final Path fileStorageLocation;
|
||||
private final Environment environment;
|
||||
private final MessageUtil messageUtil;
|
||||
|
||||
private static final String FILE_SEPARATOR = File.separator;
|
||||
|
||||
public FileStorageUtils(Environment environment, MessageUtil messageUtil) {
|
||||
this.environment = environment;
|
||||
this.fileStorageLocation = Paths.get(environment.getProperty("file.directory")).toAbsolutePath().normalize();
|
||||
String envFileDir = "";
|
||||
envFileDir = environment.getProperty("file.directory");
|
||||
if(FILE_SEPARATOR.equals("\\")) {//윈도우기반 자바시스템일 때 경로 에러방지
|
||||
envFileDir = envFileDir.replaceAll("/", "\\\\");
|
||||
}
|
||||
this.fileStorageLocation = Paths.get(envFileDir).toAbsolutePath().normalize();
|
||||
this.messageUtil = messageUtil;
|
||||
}
|
||||
|
||||
@@ -185,8 +191,9 @@ public class FileStorageUtils implements StorageUtils {
|
||||
|
||||
Path path = getStorePath(basePath);
|
||||
Path target = path.resolve(filename);
|
||||
Files.copy(file.getInputStream(), target, StandardCopyOption.REPLACE_EXISTING);
|
||||
|
||||
InputStream inputStream = file.getInputStream();
|
||||
Files.copy(inputStream, target, StandardCopyOption.REPLACE_EXISTING);
|
||||
inputStream.close(); //윈도우 시스템에서도 업로드 시 Temp폴더의 delete file 에러방지코드 추가
|
||||
return filename;
|
||||
} catch (IOException ex) {
|
||||
log.error("Could not stored file", ex);
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<configuration>
|
||||
<!DOCTYPE xml>
|
||||
<Configuration>
|
||||
|
||||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
|
||||
<encoder>
|
||||
@@ -45,4 +46,4 @@
|
||||
</root>
|
||||
</springProfile>
|
||||
|
||||
</configuration>
|
||||
</Configuration>
|
||||
|
||||
Reference in New Issue
Block a user