2016-08-15 33 views
0

我使用本地主機:8080/_ah/API /探險谷歌探索: 我不斷收到的Java BLOBSTORE和谷歌SPI AppEngine上端點

{ 
"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]" 
    } 
    ] 
} 

我的谷歌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

回答

0

Soooo .. 一個對我而言,swer真的是'設計'。

因爲我是谷歌應用程序引擎實現「休息」...我不應該修改HttpResponse返回一個「圖像」。

因此,將圖像「提供」回HttpResponse並不理想。 我應該與存儲URL直接暴露形象客戶:

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

不能說我「100%」這樣的答案,但是從我讀什麼,我相信這是正確的。