Part of the code is as follows:
Blob blob=reward.getAttachment();
OutputStream out = response.getOutputStream();
if(blob==null){
return;
}else{
InputStream inputStream = blob.getBinaryStream();
response.setContentType("image/jpeg;charset=UTF-8");
response.setCharacterEncoding("UTF-8"); int num; byte buf[] = new byte[1024]; while( (num=inputStream.read(buf))!=-1 ){ out.write(buf, 0, num); } out.flush(); out.close();