有人遇到过这种情况吗?这与在开发中工作和部署失败相反。
我的 Web 应用程序在 Deployment 上成功使用了 ImagesServiceImpl.getServingUrl(),但在开发服务器中却没有。
我在这里查看了部署环境所具有的开发环境配置中是否缺少某些内容: https ://developers.google.com/appengine/docs/java/config/appconfig#About_appengine_web_xml
还在这里查看:https ://developers.google.com/appengine/docs/java/images/overview#Development_Server 。
当我运行给我带来麻烦的代码时,控制台中会发生以下情况:
Oct 13, 2012 8:40:33 AM com.google.appengine.api.images.dev.LocalImagesService init
WARNING: No image reader found for format "ico". An ImageIO plugin must be installed to use this format with the DevAppServer.
Oct 13, 2012 8:40:33 AM com.google.appengine.api.images.dev.LocalImagesService init
WARNING: No image reader found for format "tif". An ImageIO plugin must be installed to use this format with the DevAppServer.
Oct 13, 2012 8:40:33 AM com.google.appengine.api.images.dev.LocalImagesService init
WARNING: No image reader found for format "webp". An ImageIO plugin must be installed to use this format with the DevAppServer.
Oct 13, 2012 8:40:33 AM com.google.appengine.api.images.dev.LocalImagesService init
WARNING: No image writer found for format "webp". An ImageIO plugin must be installed to use this format with the DevAppServer.
Oct 13, 2012 8:40:34 AM com.google.apphosting.utils.jetty.JettyLogger warn
WARNING: /upload
java.lang.IllegalArgumentException: Failed to read image
at com.google.appengine.api.images.ImagesServiceImpl.getServingUrl(ImagesServiceImpl.java:282)
虽然我没有 webp、ico 和 tif 解码器插件,但这应该不是问题,因为我只处理 jpeg 图像。
这是代码的一部分:
FileService fileService = FileServiceFactory.getFileService();
AppEngineFile newBlob = fileService.createNewBlobFile("image/jpeg");
// Create a new Blob file with mime-type "image/jpeg"
byte[] buffer = new byte[4096]; // 4MB
boolean lock = true;
FileWriteChannel writeChannel = fileService.openWriteChannel(newBlob, lock);
// increase the buffer size as you are reading from the
// input stream. Read the input stream into buffer
for (int n; (n = stream.read(buffer)) != -1; ){
writeChannel.write(ByteBuffer.wrap(buffer));
}
stream.close();
writeChannel.closeFinally();
BlobKey blobKey = fileService.getBlobKey(newBlob);
ImagesService imagesService = ImagesServiceFactory.getImagesService();
您可能会说,我使用较低级别的代码来接收来自用户的上传(而不是使用 getUploadUrl.
我在部署时的数据存储和我在开发中的数据存储之间的一个区别是,我在我的开发的数据存储中看到了BlobFileIndex实体类型。
感谢您的任何意见!