no message

main
이범준 9 months ago
parent ff4acb043c
commit 69e189f834

@ -217,26 +217,28 @@ public class CmmnUtil {
/** /**
* . * .
* @param staticResourcePath * @param staticResourcePath , replace
* @return * @return
*/ */
public static String copyStaticResource(String staticResourcePath) { public static String copyStaticResource(String staticResourcePath, boolean replace) {
try { try {
String folderPath = FilenameUtils.getFullPathNoEndSeparator(staticResourcePath); String folderPath = FilenameUtils.getFullPathNoEndSeparator(staticResourcePath);
String storageRoot = "files"; String storageRoot = "files";
ClassPathResource cps = new ClassPathResource(staticResourcePath);
String fileName = cps.getFilename();
File newFile = new File(storageRoot + "/" + folderPath + "/" + fileName);
if(replace && newFile.exists()) {
return storageRoot + "/" + folderPath + "/" + fileName;
}
File folder = new File(storageRoot + "/" + folderPath); File folder = new File(storageRoot + "/" + folderPath);
if(!folder.exists()) { if(!folder.exists()) {
folder.mkdirs(); folder.mkdirs();
} }
ClassPathResource cps = new ClassPathResource(staticResourcePath);
String fileName = cps.getFilename();
InputStream is = cps.getInputStream(); InputStream is = cps.getInputStream();
File newFile = new File(storageRoot + "/" + folderPath + "/" + fileName);
Files.copy(is, newFile.toPath(), StandardCopyOption.REPLACE_EXISTING); Files.copy(is, newFile.toPath(), StandardCopyOption.REPLACE_EXISTING);
return storageRoot + "/" + folderPath + "/" + fileName; return storageRoot + "/" + folderPath + "/" + fileName;

@ -473,7 +473,7 @@ public class IntegrationSearchServiceBean extends AbstractServiceBean implements
} }
if(!imagePath.startsWith("files")) { if(!imagePath.startsWith("files")) {
imagePath = CmmnUtil.copyStaticResource(imagePath); imagePath = CmmnUtil.copyStaticResource(imagePath, false);
} }
File imageFile = new File(imagePath); File imageFile = new File(imagePath);
@ -537,7 +537,7 @@ public class IntegrationSearchServiceBean extends AbstractServiceBean implements
} }
if(!imagePaths.get(i).startsWith("files")) { if(!imagePaths.get(i).startsWith("files")) {
imagePaths.set(i, CmmnUtil.copyStaticResource(imagePaths.get(i))); imagePaths.set(i, CmmnUtil.copyStaticResource(imagePaths.get(i), false));
} }
String imagePath = imagePaths.get(i); String imagePath = imagePaths.get(i);
@ -661,7 +661,7 @@ public class IntegrationSearchServiceBean extends AbstractServiceBean implements
} }
if(!orgnFilePath.startsWith("files")) { if(!orgnFilePath.startsWith("files")) {
orgnFilePath = CmmnUtil.copyStaticResource(orgnFilePath);; orgnFilePath = CmmnUtil.copyStaticResource(orgnFilePath, false);
} }
File orgnFile = new File(orgnFilePath); File orgnFile = new File(orgnFilePath);

Loading…
Cancel
Save