2012-10-13 63 views
2

任何人都有这种情况发生?这与在dev中工作和在部署中失败相反。Google App EngineCode在部署时运行,但不在开发服务器中运行

我的web应用程序在部署中成功使用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实体类型的数据存储为我的dev。

谢谢你的任何输入!

回答

1

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

你安装了最新的1.7.2。开发服务器中的getServingUrl存在一些问题。

+0

是的,我使用1.7.2。我从来没有使用webp图像(只有jpeg),所以我不认为这可能是。尽管如何安装解码器插件? – user1544470

+0

我不知道这在Java中如何工作。但是我在Python中遇到了同样的问题,并发现我必须安装一个图像库(PIP)和最新的开发服务器。 因为您只使用jpeg,所以您可以忽略日志警告。所以你的问题是与非法的争论。我发现(getServingUrl illegalargumentexception):http://stackoverflow.com/questions/6422192/create-image-serving-url-for-new-blob-file – voscausa

+0

+1,&happy 1k。 :) –

相关问题