} Below code is used to download the file . The content types and the header are changed manually(as of now for testing ) to match the file types . public void downloadFile(FacesContext facesContext, OutputStream outputStream) { DCBindingContainer lBindingContainer = (DCBindingContainer)BindingContext.getCurrent().getCurrentBindingsEntry(); BlobDomain blob ; DCIteratorBinding lBinding = lBindingContainer.findIteratorBinding("<iterator name>"); blob = (BlobDomain)lBinding.getCurrentRow().getAttribute("FileAttach"); String filename = (String)lBinding.getCurrentRow().getAttribute("FileName"); HttpServletResponse response = (HttpServletResponse)ectx.getResponse(); response.setContentType("docx"); response.setHeader("Content-Disposition", "attachment;filename=\"" + fileName + ".docx"+ "\""); try { System.out.println("blob.getLength()" + blob.getLength()); OutputStream os = response.getOutputStream() ; System.out.println("blob.getCharacterOutputStream()" + blob.getCharacterStream()); System.out.println("filename" + filename); //copyStream(blob.getInputStream(), outputStream); copyStream(blob.getInputStream(), os); System.out.println("os" + os.toString()); // blob.closeInputStream(); //outputStream.flush(); } catch (IOException e) { e.printStackTrace(); } finally { try { outputStream.flush(); outputStream.close(); } catch (IOException e) { e.printStackTrace(); } } } Could someone help me in resolving this issue . |