I have a class in which I have decrlared a serialized class to store image data
@Persistent(serialized = "true") private DownloadableFile imageLogoFile;
Implementation of the class
public class DownloadableFile implements Serializable {
public DownloadableFile(byte[] content, String filename, String mimeType) { super(); this.content = content; this.filename = filename; this.mimeType = mimeType; } private static final long serialVersionUID = -8497358622042084708L; private byte[] content; private String filename; private String mimeType; public DownloadableFile() { } }
showlogo is a servlet that is supposed to fetch content from datastore but all its call are returning null whereas the blob is visible in appwrench.
Place where its expected to fecth the image data
final Image logoImage = new Image();
logoImage.setUrl("/showlogo");
logoImage.setHeight("100px");
logoImage.setWidth("100px");
Edit : Now the image data is getting saved and fetched but the image is stretched out. I have tried giving height/width etc.,
Servlet code :
com.sms.DownloadableFile df = w.getImageLogoFile();
if (df != null){
String filen = df.getFilename();
response.setHeader("Content-Disposition", "filename="+filen);
String mime = df.getMimeType();
response.setContentType(mime);
byte[] b = df.getContent();
//Base64.encode(b);
response.setContentLength(b.length);
ServletOutputStream out = response.getOutputStream();
out.write(b);
// Pipe data here
out.flush();
out.close();
}
and you didn't put that field in the fetch group, so it isn't fetched.