• Y
  • List All
  • Feedback
    • This Project
    • This Group
    • All Projects
Profile Account settings Log out
  • Favorite
  • Project
  • All
Loading...
  • Log in
  • Sign up
itnAdmin / itsm_sync star
  • Project homeH
  • CodeC
  • IssueI
  • Pull requestP
  • Review R
  • MilestoneM
  • BoardB
  • Files
  • Commit
  • Branches
itsm_syncsrcmainjavaegovframeworkcomcmmwebEgovImageProcessController.java
Download as .zip file
File name
Commit message
Commit date
DATABASE
첫번째 커밋
07-30
service/impl
첫번째 커밋
07-30
src/main
조직도 삭제 쿼리 및 로직 추가
11-25
web
첫번째 커밋
07-30
.gitignore
첫번째 커밋
07-30
pom.xml
첫번째 커밋
07-30
searchQuery.sql
첫번째 커밋
07-30
File name
Commit message
Commit date
java/egovframework
조직도 삭제 쿼리 및 로직 추가
11-25
resources
조직도 삭제 쿼리 및 로직 추가
11-25
webapp
조직도 삭제 쿼리 및 로직 추가
11-25
File name
Commit message
Commit date
com
첫번째 커밋
07-30
let
조직도 삭제 쿼리 및 로직 추가
11-25
web
첫번째 커밋
07-30
File name
Commit message
Commit date
cmm
첫번째 커밋
07-30
sym/log/ulg
첫번째 커밋
07-30
usr/search/web
첫번째 커밋
07-30
uss/ion
첫번째 커밋
07-30
utl
첫번째 커밋
07-30
File name
Commit message
Commit date
captcha
첫번째 커밋
07-30
filter
첫번째 커밋
07-30
selfauth
첫번째 커밋
07-30
service
첫번째 커밋
07-30
taglibs
첫번째 커밋
07-30
util
첫번째 커밋
07-30
web
첫번째 커밋
07-30
AltibaseClobStringTypeHandler.java
첫번째 커밋
07-30
ComDefaultCodeVO.java
첫번째 커밋
07-30
ComDefaultVO.java
첫번째 커밋
07-30
EgovComCrossSiteHndlr.java
첫번째 커밋
07-30
EgovComExcepHndlr.java
첫번째 커밋
07-30
EgovComOthersExcepHndlr.java
첫번째 커밋
07-30
EgovComTraceHandler.java
첫번째 커밋
07-30
EgovMessageSource.java
첫번째 커밋
07-30
EgovMultiPartEmail.java
첫번째 커밋
07-30
EgovWebUtil.java
첫번째 커밋
07-30
FacebookAPI.java
첫번째 커밋
07-30
ImagePaginationRenderer.java
첫번째 커밋
07-30
ImagePaginationRendererListTop.java
첫번째 커밋
07-30
ImagePaginationRendererWeb.java
첫번째 커밋
07-30
LoginVO.java
첫번째 커밋
07-30
SessionVO.java
첫번째 커밋
07-30
UserVO.java
첫번째 커밋
07-30
File name
Commit message
Commit date
EgovBindingInitializer.java
첫번째 커밋
07-30
EgovComUtlController.java
첫번째 커밋
07-30
EgovFileDownloadController.java
첫번째 커밋
07-30
EgovFileMngController.java
첫번째 커밋
07-30
EgovImageProcessController.java
첫번째 커밋
07-30
EgovMultipartResolver.java
첫번째 커밋
07-30
rosewiper 07-30 45394a7 첫번째 커밋 UNIX
Raw Open in browser Change history
package egovframework.com.cmm.web; import java.io.BufferedInputStream; import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileInputStream; import java.util.Map; import javax.annotation.Resource; import javax.servlet.http.HttpServlet; import javax.servlet.http.HttpServletResponse; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.stereotype.Controller; import org.springframework.ui.ModelMap; import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestParam; import egovframework.com.cmm.SessionVO; import egovframework.com.cmm.service.EgovFileMngService; import egovframework.com.cmm.service.FileVO; /** * @Class Name : EgovImageProcessController.java * @Description : * @Modification Information * * 수정일 수정자 수정내용 * ------- ------- ------------------- * 2009. 4. 2. 이삼섭 * 2011.08.31. JJY 경량환경 템플릿 커스터마이징버전 생성 * * @author 공통 서비스 개발팀 이삼섭 * @since 2009. 4. 2. * @version * @see * */ @SuppressWarnings("serial") @Controller public class EgovImageProcessController extends HttpServlet { @Resource(name = "EgovFileMngService") private EgovFileMngService fileService; 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; new FileInputStream(file); 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()); } } } } @SuppressWarnings("resource") @RequestMapping("/cmm/fms/getAssetImage.do") public void getAssetImage(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); FileVO fvo = fileService.selectFileAssertInf(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; new FileInputStream(file); 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(); } } 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()); } } } } @SuppressWarnings("resource") @RequestMapping("/cmm/fms/getUserImage.do") public void getUserImage(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); FileVO fvo = fileService.selectFileUserInf(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; new FileInputStream(file); 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(); } } 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()); } } } } }

          
        
    
    
Copyright Yona authors & © NAVER Corp. & NAVER LABS Supported by NAVER CLOUD PLATFORM

or
Sign in with github login with Google Sign in with Google
Reset password | Sign up