getServingUrl()在Java中使用Google Cloud Storage值的方法抛出异常

时间:2017-02-18 11:41:48

标签: java google-app-engine google-cloud-datastore google-api-java-client google-app-engine-python

我一直在尝试使用Java生成Google Cloud图片网址的代码块,其中my-bucket是Google存储桶名称。

String key = "/gs/Buckets/my-bucket/photo/1/content.jpeg"; 
ImagesService imagesService = ImagesServiceFactory.getImagesService();
ServingUrlOptions options = ServingUrlOptions.Builder
        .withGoogleStorageFileName(key)
        .imageSize(100);
String servingUrl = imagesService.getServingUrl(options);

但我收到错误

Exception in thread "main" com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'blobstore' or call 'CreateEncodedGoogleStorageKey()' was not found.
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:111)
at com.google.apphosting.api.ApiProxy.makeSyncCall(ApiProxy.java:66)
at com.google.appengine.api.blobstore.BlobstoreServiceImpl.createGsBlobKey(BlobstoreServiceImpl.java:312)
at com.google.appengine.api.images.ImagesServiceImpl.getServingUrl(ImagesServiceImpl.java:266)
at com.example.appengine.images.ImagesServlet.main(ImagesServlet.java:53)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:497)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:147)

我已尝试过键值

String key = "/gs/Buckets/my-bucket/photo/1/content.jpeg";

String key = "/gs/my-bucket/photo/1/content.jpeg";

但是这会得到同样的错误。

更新

https://stackoverflow.com/a/42333834/4909177尝试了这个答案,并得到了同样的错误。

0 个答案:

没有答案