I am using an byte array byte[]
to store images in my databse, using JPA:
@Lob @Basic(fetch = FetchType.LAZY)
@Column(length=16777000)
private byte[] image;
This is how I upload the images, before storing them in the database:
public void uploadFile(org.primefaces.event.FileUploadEvent event) {
byte[] img = event.getFile().getContents();
// and so on...
}
Then, I am reading the image from the database and want to display it using PrimeFaces/JSF. Something like:
<p:galleria value="#{bean.images}" var="image"
panelWidth="500" panelHeight="313" showCaption="true">
<p:graphicImage name="image"
alt="Some description..." title="Some title..." />
</p:galleria>
To do that, I need to convert the byte[]
array back to a displayable image. Does anybody know how to do this?