0
votes

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();
}
1
Why is this tagged gwt? I don't see anything about gwt in your question.Peter Recore
the Image call is from GWT module. Normal call to localhost:8080/showlogo works but fetches 0 size image.dhaval

1 Answers

1
votes

and you didn't put that field in the fetch group, so it isn't fetched.