日期:2014-05-16 浏览次数:20396 次
//FileInputStream str; try { //str = new FileInputStream(enBO.getFileName()); InputStream fs=enBO.getFile().getInputStream(); PreparedStatement pstmt; pstmt = this.getSession().connection().prepareStatement("insert into file_content values("+enBO.getAttachmentId()+",?)"); //pstmt.setBinaryStream(1,str,str.available()); pstmt.setBinaryStream(1,fs,fs.available()); pstmt.execute(); pstmt.close(); fs.close(); //str.close(); } catch (IOException e) { e.printStackTrace(); } catch (HibernateException e) { e.printStackTrace(); } catch (SQLException e) { e.printStackTrace(); }
?
FileContent fileContent = contactService.getFileContent(fileContentId); response.reset(); // response.addHeader("Content-Disposition", "attachment;filename=" + fileContent.getAttachment().getFileName()); response.addHeader("Content-Length", ""+fileContent.getFileContent().length); response.setContentType("bin"); OutputStream toClient = new BufferedOutputStream(response .getOutputStream()); response.setContentType("application/octet-stream"); toClient.write(fileContent.getFileContent()); toClient.flush(); toClient.close();?
?
?
?
?
?
?
?
?
?
?
?
?