hehihoho3@gmail.com 6 days ago
포토 getImage.do 컨트롤러 이동
@aeea59129289209cd6496f97164f9ac147851854
src/main/java/kcc/com/cmm/web/EgovFileDownloadController.java
--- src/main/java/kcc/com/cmm/web/EgovFileDownloadController.java
+++ src/main/java/kcc/com/cmm/web/EgovFileDownloadController.java
@@ -2,6 +2,7 @@
 
 import java.io.BufferedInputStream;
 import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.FileInputStream;
 import java.io.IOException;
@@ -17,10 +18,12 @@
 import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Controller;
+import org.springframework.ui.ModelMap;
 import org.springframework.util.FileCopyUtils;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import kcc.com.cmm.SessionVO;
 import kcc.com.cmm.service.EgovFileMngService;
 import kcc.com.cmm.service.FileVO;
 
@@ -120,7 +123,114 @@
 			response.setContentType("application/octet-stream;charset=UTF-8");
 		}
 	}
+	/**
+	 * 첨부된 이미지에 대한 미리보기 기능을 제공한다.
+	 *
+	 * @param atchFileId
+	 * @param fileSn
+	 * @param sessionVO
+	 * @param model
+	 * @param response
+	 * @throws Exception
+	 */
+	@SuppressWarnings("resource")
+	@RequestMapping("/cmm/fms/getImage.do")
+	public void getImageInf(SessionVO sessionVO, ModelMap model, @RequestParam Map<String, Object> commandMap, HttpServletResponse response) throws Exception {
 
+		System.out.println(" :: /cmm/fms/getImage.do ::");
+		
+		String atchFileId = (String) commandMap.get("atchFileId");
+		String fileSn = (String) commandMap.get("fileSn");
+		String isThumbFile = (String) commandMap.get("isThumbFile");
+		
+		FileVO vo = new FileVO();
+
+		vo.setAtchFileId(atchFileId);
+		vo.setFileSn(fileSn);
+
+		//------------------------------------------------------------
+		// fileSn이 없는 경우 마지막 파일 참조
+		//------------------------------------------------------------
+		if (fileSn == null || fileSn.equals("")) {
+			int newMaxFileSN = fileService.getMaxFileSN(vo);
+			vo.setFileSn(Integer.toString(newMaxFileSN - 1));
+		}
+		//------------------------------------------------------------
+		FileVO fvo = fileService.selectFileInf(vo);
+
+		String fileNm = fvo.getStreFileNm();
+		// 섬네일 이미지 경우
+		if (isThumbFile != null && ("thumbFile").equals(isThumbFile) && fvo.getThumbFileNm() != null) {
+			fileNm = fvo.getThumbFileNm();
+		}
+		
+		File file = new File(fvo.getFileStreCours(), fileNm);
+		
+		FileInputStream fis = null;
+		try {
+			new FileInputStream(file);
+		}catch(Exception e) {}
+		
+		BufferedInputStream in = null;
+		ByteArrayOutputStream bStream = null;
+		try {
+			fis = new FileInputStream(file);
+			in = new BufferedInputStream(fis);
+			bStream = new ByteArrayOutputStream();
+			int imgByte;
+			/*while ((imgByte = in.read()) != -1) {
+				bStream.write(imgByte);
+			}*/
+			
+			byte[] outputByte=new byte[104096];
+			while ((imgByte =in.read(outputByte, 0, 4096 )) > 0 ) {
+				bStream.write(outputByte,0,imgByte);
+			}
+			String type = "";
+			if (fvo.getFileExtsn() != null && !"".equals(fvo.getFileExtsn())) {
+				if ("jpg".equals(fvo.getFileExtsn().toLowerCase())) {
+					type = "image/jpeg";
+				} else {
+					type = "image/" + fvo.getFileExtsn().toLowerCase();
+				}
+				//type = "image/" + fvo.getFileExtsn().toLowerCase();
+
+			} else {
+				LOGGER.debug("Image fileType is null.");
+			}
+
+			response.setHeader("Content-Type", type);
+			response.setContentLength(bStream.size());
+			bStream.writeTo(response.getOutputStream());
+			response.getOutputStream().flush();
+			response.getOutputStream().close();
+
+		} catch (Exception e) {
+			LOGGER.debug("{}", e);
+		} finally {
+			if (bStream != null) {
+				try {
+					bStream.close();
+				} catch (Exception est) {
+					LOGGER.debug("IGNORED: {}", est.getMessage());
+				}
+			}
+			if (in != null) {
+				try {
+					in.close();
+				} catch (Exception ei) {
+					LOGGER.debug("IGNORED: {}", ei.getMessage());
+				}
+			}
+			if (fis != null) {
+				try {
+					fis.close();
+				} catch (Exception efis) {
+					LOGGER.debug("IGNORED: {}", efis.getMessage());
+				}
+			}
+		}
+	}
 	/**
 	 * 첨부파일로 등록된 파일에 대하여 다운로드를 제공한다.
 	 *
src/main/java/kcc/com/cmm/web/EgovImageProcessController.java
--- src/main/java/kcc/com/cmm/web/EgovImageProcessController.java
+++ src/main/java/kcc/com/cmm/web/EgovImageProcessController.java
@@ -46,110 +46,5 @@
 
 	private static final Logger LOGGER = LoggerFactory.getLogger(EgovImageProcessController.class);
 
-	/**
-	 * 첨부된 이미지에 대한 미리보기 기능을 제공한다.
-	 *
-	 * @param atchFileId
-	 * @param fileSn
-	 * @param sessionVO
-	 * @param model
-	 * @param response
-	 * @throws Exception
-	 */
-	@SuppressWarnings("resource")
-	@RequestMapping("/cmm/fms/getImage.do")
-	public void getImageInf(SessionVO sessionVO, ModelMap model, @RequestParam Map<String, Object> commandMap, HttpServletResponse response) throws Exception {
-
-		String atchFileId = (String) commandMap.get("atchFileId");
-		String fileSn = (String) commandMap.get("fileSn");
-		String isThumbFile = (String) commandMap.get("isThumbFile");
-		
-		FileVO vo = new FileVO();
-
-		vo.setAtchFileId(atchFileId);
-		vo.setFileSn(fileSn);
-
-		//------------------------------------------------------------
-		// fileSn이 없는 경우 마지막 파일 참조
-		//------------------------------------------------------------
-		if (fileSn == null || fileSn.equals("")) {
-			int newMaxFileSN = fileService.getMaxFileSN(vo);
-			vo.setFileSn(Integer.toString(newMaxFileSN - 1));
-		}
-		//------------------------------------------------------------
-		FileVO fvo = fileService.selectFileInf(vo);
-
-		String fileNm = fvo.getStreFileNm();
-		// 섬네일 이미지 경우
-		if (isThumbFile != null && ("thumbFile").equals(isThumbFile) && fvo.getThumbFileNm() != null) {
-			fileNm = fvo.getThumbFileNm();
-		}
-		
-		File file = new File(fvo.getFileStreCours(), fileNm);
-		
-		FileInputStream fis = null;
-		try {
-			new FileInputStream(file);
-		}catch(Exception e) {}
-		
-		BufferedInputStream in = null;
-		ByteArrayOutputStream bStream = null;
-		try {
-			fis = new FileInputStream(file);
-			in = new BufferedInputStream(fis);
-			bStream = new ByteArrayOutputStream();
-			int imgByte;
-			/*while ((imgByte = in.read()) != -1) {
-				bStream.write(imgByte);
-			}*/
-			
-			byte[] outputByte=new byte[104096];
-			while ((imgByte =in.read(outputByte, 0, 4096 )) > 0 ) {
-				bStream.write(outputByte,0,imgByte);
-			}
-			String type = "";
-			if (fvo.getFileExtsn() != null && !"".equals(fvo.getFileExtsn())) {
-				if ("jpg".equals(fvo.getFileExtsn().toLowerCase())) {
-					type = "image/jpeg";
-				} else {
-					type = "image/" + fvo.getFileExtsn().toLowerCase();
-				}
-				//type = "image/" + fvo.getFileExtsn().toLowerCase();
-
-			} else {
-				LOGGER.debug("Image fileType is null.");
-			}
-
-			response.setHeader("Content-Type", type);
-			response.setContentLength(bStream.size());
-			bStream.writeTo(response.getOutputStream());
-			response.getOutputStream().flush();
-			response.getOutputStream().close();
-
-		} catch (Exception e) {
-			LOGGER.debug("{}", e);
-		} finally {
-			if (bStream != null) {
-				try {
-					bStream.close();
-				} catch (Exception est) {
-					LOGGER.debug("IGNORED: {}", est.getMessage());
-				}
-			}
-			if (in != null) {
-				try {
-					in.close();
-				} catch (Exception ei) {
-					LOGGER.debug("IGNORED: {}", ei.getMessage());
-				}
-			}
-			if (fis != null) {
-				try {
-					fis.close();
-				} catch (Exception efis) {
-					LOGGER.debug("IGNORED: {}", efis.getMessage());
-				}
-			}
-		}
-	}
+	
 }
Add a comment
List