에디터 사진 업로드 중간저장.
parent
d9cd77b905
commit
e21c405437
|
|
@ -50,6 +50,8 @@ public class EditorController {
|
||||||
|
|
||||||
@Value("${file.dir}")
|
@Value("${file.dir}")
|
||||||
protected String fileDir;
|
protected String fileDir;
|
||||||
|
@Value("${file.dir.editor}")
|
||||||
|
protected String editorPath;
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private Environment env;
|
private Environment env;
|
||||||
|
|
@ -72,7 +74,7 @@ public class EditorController {
|
||||||
String extNm = "." + attach_file_Name.substring( attach_file_Name.lastIndexOf( "." ) + 1, attach_file_Name.length());
|
String extNm = "." + attach_file_Name.substring( attach_file_Name.lastIndexOf( "." ) + 1, attach_file_Name.length());
|
||||||
if(".jpg,.png,.jpeg".indexOf(extNm.toLowerCase()) > -1) {
|
if(".jpg,.png,.jpeg".indexOf(extNm.toLowerCase()) > -1) {
|
||||||
|
|
||||||
File dir = new File(fileDir + year);
|
File dir = new File(fileDir+File.separator+editorPath);
|
||||||
if (!dir.exists()) {
|
if (!dir.exists()) {
|
||||||
try{
|
try{
|
||||||
|
|
||||||
|
|
@ -91,10 +93,10 @@ public class EditorController {
|
||||||
System.out.println("Directory already exists");
|
System.out.println("Directory already exists");
|
||||||
}
|
}
|
||||||
|
|
||||||
File file = new File(fileDir + year, attach_save_Name + extNm);
|
File file = new File(fileDir+File.separator+editorPath, attach_save_Name + extNm);
|
||||||
|
|
||||||
FileCopyUtils.copy(mFile.getBytes(), file);
|
FileCopyUtils.copy(mFile.getBytes(), file);
|
||||||
String webPath = "http://localhost:8080/" + fileDir + year + attach_save_Name + extNm;
|
String webPath = "http://localhost:8080/file/editorFileDisplay?fileNm=" + attach_save_Name + extNm;
|
||||||
|
|
||||||
result.set("result", "success");
|
result.set("result", "success");
|
||||||
List<ParamMap> addmsg = new ArrayList<>();
|
List<ParamMap> addmsg = new ArrayList<>();
|
||||||
|
|
|
||||||
|
|
@ -9,6 +9,7 @@ import com.dbnt.faisp.main.fpiMgt.affairResult.service.ResultService;
|
||||||
import com.dbnt.faisp.main.ivsgtMgt.boardInvestigation.service.BoardInvestigationService;
|
import com.dbnt.faisp.main.ivsgtMgt.boardInvestigation.service.BoardInvestigationService;
|
||||||
import com.dbnt.faisp.main.publicBoard.service.PublicBoardService;
|
import com.dbnt.faisp.main.publicBoard.service.PublicBoardService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.springframework.beans.factory.annotation.Value;
|
||||||
import org.springframework.core.io.FileSystemResource;
|
import org.springframework.core.io.FileSystemResource;
|
||||||
import org.springframework.core.io.Resource;
|
import org.springframework.core.io.Resource;
|
||||||
import org.springframework.http.HttpHeaders;
|
import org.springframework.http.HttpHeaders;
|
||||||
|
|
@ -40,6 +41,32 @@ public class FileController {
|
||||||
private final BoardInvestigationService boardInvestigationService;
|
private final BoardInvestigationService boardInvestigationService;
|
||||||
private final FishingBoatService fishingBoatService;
|
private final FishingBoatService fishingBoatService;
|
||||||
|
|
||||||
|
@Value("${file.dir}")
|
||||||
|
protected String fileDir;
|
||||||
|
@Value("${file.dir.editor}")
|
||||||
|
protected String editorPath;
|
||||||
|
|
||||||
|
@GetMapping("/editorFileDisplay")
|
||||||
|
public ResponseEntity<Resource> editorFileDisplay(HttpServletRequest request,
|
||||||
|
HttpServletResponse response,
|
||||||
|
String fileNm) {
|
||||||
|
|
||||||
|
String pathStr = fileDir+File.separator+editorPath+File.separator+fileNm;
|
||||||
|
Resource resource = new FileSystemResource(pathStr);
|
||||||
|
if(!resource.exists()){
|
||||||
|
return new ResponseEntity<>(HttpStatus.NOT_FOUND);
|
||||||
|
}
|
||||||
|
HttpHeaders header = new HttpHeaders();
|
||||||
|
Path filePath = null;
|
||||||
|
try {
|
||||||
|
filePath = Paths.get(pathStr);
|
||||||
|
header.add("Content-type", Files.probeContentType(filePath));
|
||||||
|
}catch (IOException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return new ResponseEntity<Resource>(resource, header, HttpStatus.OK);
|
||||||
|
}
|
||||||
|
|
||||||
@GetMapping("/fileDisplay")
|
@GetMapping("/fileDisplay")
|
||||||
public ResponseEntity<Resource> fileDisplay(HttpServletRequest request,
|
public ResponseEntity<Resource> fileDisplay(HttpServletRequest request,
|
||||||
HttpServletResponse response,
|
HttpServletResponse response,
|
||||||
|
|
@ -62,6 +89,7 @@ public class FileController {
|
||||||
}
|
}
|
||||||
return new ResponseEntity<Resource>(resource, header, HttpStatus.OK);
|
return new ResponseEntity<Resource>(resource, header, HttpStatus.OK);
|
||||||
}
|
}
|
||||||
|
|
||||||
@GetMapping("/fileDownload")
|
@GetMapping("/fileDownload")
|
||||||
public void fileDownload(HttpServletRequest request,
|
public void fileDownload(HttpServletRequest request,
|
||||||
HttpServletResponse response,
|
HttpServletResponse response,
|
||||||
|
|
|
||||||
|
|
@ -6,12 +6,13 @@ spring.servlet.multipart.max-file-size=200MB
|
||||||
spring.servlet.multipart.max-request-size=500MB
|
spring.servlet.multipart.max-request-size=500MB
|
||||||
|
|
||||||
#file
|
#file
|
||||||
file.dir=C:\\faispUploadFiles
|
file.dir=/docker/faisp/uploadFiles
|
||||||
file.dir.vulnerable=/vulnerable
|
file.dir.vulnerable=/vulnerable
|
||||||
file.dir.part=/part
|
file.dir.part=/part
|
||||||
file.dir.equip=/equip
|
file.dir.equip=/equip
|
||||||
file.dir.sailor=sailor
|
file.dir.sailor=sailor
|
||||||
file.dir.affair=affair
|
file.dir.affair=affair
|
||||||
|
file.dir.editor=editor
|
||||||
|
|
||||||
#thymeleaf
|
#thymeleaf
|
||||||
spring.thymeleaf.prefix=classpath:templates/
|
spring.thymeleaf.prefix=classpath:templates/
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue