I have a method which returns a byte array of an image. The problem is when i try to show it on the screen with StreamedContent i get Error in streaming dynamic resource.
imageBean:
BufferedImage bImage = ImageIO.read(new File("imagepath"));
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ImageIO.write(bImage, "png", bos );
byte [] image = bos.toByteArray();
ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(image);
imageContent = new DefaultStreamedContent(byteArrayInputStream, "image/png");
xhtml:
<p:graphicImage value="#{imageBean.imageContent}"></p:graphicImage>
Any idea how to fix it or why i am getting this error ?