public void download ( ) { DataKeeperService service = DataKeeperUtils . getService ( ) ; setDocumentId ( Integer . parseInt ( FacesUtils . getRequest ( ) . getParameter ( "documentId" ) ) ) ; DocumentInfo document = service . findDocumentByDocumentId ( getDocumentId ( ) ) ; final HttpServletResponse response = ( HttpServletResponse ) FacesContext . getCurrentInstance ( ) . getExternalContext ( ) . getResponse ( ) ; ServletOutputStream out = null ; try { out = response . getOutputStream ( ) ; out . write ( document . getData ( ) , 0 , 4096 ) ; } catch ( IOException e ) { } finally { if ( out != null ) { try { out . flush ( ) ; out . close ( ) ; } catch ( IOException e ) { } } } FacesContext . getCurrentInstance ( ) . responseComplete ( ) ; }
Download file used for downloading photo .