【问题标题】:java BlobStore and Google SPI AppEngine endpointjava Blob 存储和 Google API App Engine 端点
【发布时间】:2016-12-21 06:30:29
【问题描述】:

我正在使用 localhost:8080/_ah/api/explorer 谷歌探索: 我不断得到

{
 "error": {
  "message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not construct instance of javax.servlet.http.HttpServletResponse, problem: abstract types can only be instantiated with additional type information\n at [Source: N/A; line: -1, column: -1]",
  "code": 400,
  "errors": [
   {
    "domain": "global",
    "reason": "badRequest",
    "message": "com.google.appengine.repackaged.org.codehaus.jackson.map.JsonMappingException: Can not construct instance of javax.servlet.http.HttpServletResponse, problem: abstract types can only be instantiated with additional type information\n at [Source: N/A; line: -1, column: -1]"
   }
  ]
 }

我的 Google SPI 代码是:

    @ApiMethod(name = "findBillImage", httpMethod = ApiMethod.HttpMethod.GET )
public void findImage(HttpServletResponse httpServletResponse ,  @Named("blobkey") String blobKeyValue)   throws IOException {
     BlobKey blobKey = new BlobKey( blobKeyValue );
     BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();          
     blobstoreService.serve(blobKey, httpServletResponse);       
}

每当我尝试向 HttpServletResponse 写入任何内容时,我都会收到此错误。我不知道为什么我无法写入 httpServletResponse

【问题讨论】:

    标签: java google-app-engine blobstore


    【解决方案1】:

    太好了.. 就我而言,答案确实是“设计”。

    由于我使用谷歌应用引擎实现“REST”...我不应该修改 HttpResponse 以返回“图像”。

    所以将图像“服务”回 HttpResponse 并不理想。 我应该将带有存储 URL 的图像直接公开给客户端。:

    https://storage.cloud.google.com/myapp.appspot.com/20160603_154924.jpg
    

    不能说我“100%”喜欢这个答案,但从我阅读的内容来看,我相信这是正确的。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-10-10
      • 1970-01-01
      • 2011-12-24
      • 2013-11-05
      • 1970-01-01
      相关资源
      最近更新 更多