4.2.x <- contribution

This commit is contained in:
yongfire38
2024-07-12 15:41:03 +09:00
parent f1478b722e
commit b7a255d112
54 changed files with 1241 additions and 11741 deletions

View File

@@ -46,6 +46,10 @@ dependencies {
implementation 'org.springframework.cloud:spring-cloud-sleuth-zipkin'
implementation 'org.springframework.cloud:spring-cloud-starter-openfeign'
implementation 'org.springframework.cloud:spring-cloud-starter-circuitbreaker-resilience4j'
implementation 'org.apache.tomcat:tomcat-annotations-api:9.0.73'
implementation 'org.apache.tomcat.embed:tomcat-embed-core:9.0.73'
implementation 'org.apache.tomcat.embed:tomcat-embed-el:9.0.73'
implementation 'org.apache.tomcat.embed:tomcat-embed-websocket:9.0.73'
implementation 'net.logstash.logback:logstash-logback-encoder:7.4' // logstash logback
implementation 'commons-io:commons-io:2.13.0'
implementation 'commons-net:commons-net:3.9.0' // FTPClient
@@ -62,7 +66,7 @@ dependencies {
// openapi docs
implementation 'org.springdoc:springdoc-openapi-webmvc-core:1.7.0'
annotationProcessor 'org.springframework.boot:spring-boot-configuration-processor'
annotationProcessor "org.springframework.boot:spring-boot-configuration-processor"
// lombok
implementation 'org.projectlombok:lombok'

View File

@@ -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);
}
/**

View File

@@ -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);

View File

@@ -46,4 +46,4 @@
</root>
</springProfile>
</Configuration>
</Configuration>