cannot fetch image data in gwt google datastore - image is strected out

点点圈 提交于 2019-12-08 09:37:39

问题


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:


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



来源:https://stackoverflow.com/questions/2018597/cannot-fetch-image-data-in-gwt-google-datastore-image-is-strected-out

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!