@RequestMapping(value = "/downLoadHaBscMttrPhoto.do")
public void selectPhoto(HttpServletRequest request, HttpServletResponse response) throws NexacroException, ServletRequestBindingException, IOException {
String kornFlnm = ServletRequestUtils.getStringParameter(request, "kornFlnm");
String empno = ServletRequestUtils.getStringParameter(request, "empno");
HaBscMttrVo vo = haBscMttrService.selectByteImg(empno);
byte[] blobData = vo.getPhotoBt();// BLOB 형식의 이미지를 byte로 가져온다
if (blobData == null) {
return ;
}
String originalFilename = kornFlnm.replaceAll(" ", "");
String filename = empno + "_" + originalFilename + ".jpg";
// 파일 이름을 URL 인코딩 처리
String encodedFilename = URLEncoder.encode(filename, "UTF-8").replaceAll("\\+", "%20");
response.setContentType("application/octet-stream");
response.setHeader("Content-Disposition", "attachment; filename*=UTF-8''" + encodedFilename);
response.setContentLength(blobData.length);
try (OutputStream outputStream = response.getOutputStream()) {
outputStream.write(blobData);
outputStream.flush();
} catch (IOException e) {
e.printStackTrace();
response.setStatus(HttpServletResponse.SC_INTERNAL_SERVER_ERROR);
}
}
'업무용 > nexacro' 카테고리의 다른 글
this.close() 이후 값 받는법// rowType (0) | 2024.02.19 |
---|---|
theme:// || static ||edit||button||calender||div|| 모달창 || this.close("cancel"); (0) | 2023.12.06 |