I have created web-application using JSF 2.0 and mysql.
I am storing images in DB using MEDIUMBLOB. When I try to load image, I am able to see those images. However if the image size is big (1 MB or more), I can see half or 3/4th image on the browser.
Any idea how to overcome this issue? Do I need to set any variable in JSF or MySQL?
I know I should have saved the images over disk instead of DB, however this was client requirement. Client wanted to backup data and provide it to someone else and client don't want to backup DB and images also.
Edit 1
Do I need to set any variables on mysql like query_cache.
Edit 2
When I download same image and put below code it works perfectly.
<h:graphicImage value="images/myImage4.png" width="50%" />
Edit 3
code is as below.
<h:graphicImage value="DisplayImage?mainID=drawing" />
DisplayImage.java
String imgLen = rs1.getString(1);
int len = imgLen.length();
byte[] rb = new byte[len];
InputStream readImg = rs1.getBinaryStream(1);
InputStream inputStream = readImg;
int index = readImg.read(rb, 0, len);
response.reset();
response.setHeader("Content-Length", String.valueOf(len));
response.setHeader("Content-disposition", "inline;filename=/file.png");
response.setContentType("image/png");
response.getOutputStream().write(rb, 0, len);
response.getOutputStream().flush();
When I print len I get value as len=1548432