2

有人遇到过这种情况吗?这与在开发中工作和部署失败相反。

我的 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实体类型。

感谢您的任何意见!

4

1 回答 1

1

来自文档:Java 开发服务器使用 ImageIO 框架来模拟 Image 服务。不支持“手气不错”的照片增强功能。只有安装了合适的解码器插件后,才支持 WEBP 图像格式。例如,可以使用 Java VP8 解码器插件。

有没有安装最新的 1.7.2。开发服务器中的 getServingUrl 修复了一些问题。

于 2012-10-13T13:46:09.730 回答