无法在 gwt google 数据存储中获取图像数据 - 图像被拉伸
我有一个类,在其中声明了一个序列化类来存储图像数据
@Persistent(序列化=“true”) 私有可下载文件 imageLogoFile;
类的实现
public class DownloadableFile implements Serializable {
public DownloadableFile(byte[] content, String filename, String mimeType) { 极好的(); this.内容=内容; this.文件名=文件名; this.mimeType = mimeType; } 私有静态最终长serialVersionUID = -8497358622042084708L; 私有字节[]内容; 私有字符串文件名; 私有字符串 mimeType; 公共下载文件(){ } showlogo
是一个 servlet,它应该从数据存储区获取内容,但它的所有调用都返回 null,而 blob 在 appwrench 中可见。
预期影响图像数据的位置
final Image logoImage = new Image();
logoImage.setUrl("/showlogo");
logoImage.setHeight("100px");
logoImage.setWidth("100px");
编辑: 现在正在保存和获取图像数据,但图像被拉伸。我尝试过给出高度/宽度等,
Servlet 代码:
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();
}
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();
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
并且您没有将该字段放入提取组中,因此不会提取它。
and you didn't put that field in the fetch group, so it isn't fetched.