반응형
1. 입력
try {
VoFile file = new VoFile();
file.setFile_cont(multi.getBytes()); // MultipartFile
String fileSeq = dao.insertFile(file); // DB Insert
} catch (Exception e) {
e.printStackTrace();
}
2. 출력
byte[] imgFile = (byte[]) model.get("fileCont");
//중간 생략
InputStream is = null;
try {
is = new ByteArrayInputStream(imgFile);
ServletOutputStream os = response.getOutputStream();
int binaryRead;
while ((binaryRead = is.read()) != -1) {
os.write(binaryRead);
}
} catch(Exception e){
e.printStackTrace();
} finally {
if (is != null)
try { is.close(); }
catch (IOException ex) { }
}
반응형
'Back > Spring Java' 카테고리의 다른 글
JPA findAll Specification (0) | 2020.01.14 |
---|---|
BeanUtils.copyProperties (0) | 2019.12.23 |
Spring Security Login (2) | 2019.12.18 |
가변인자 Varargs (0) | 2019.12.18 |
제네릭(Generic) 문법 (0) | 2019.11.25 |