我正在使用GAE为一个项目编写此代码。我没有使用Blobstore,但我需要使用servingUrl方法。
GcsFilename gcsFilename = new GcsFilename(myBucket, myFileName);
BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKey = blobstoreService.createGsBlobKey(
"/gs/" + gcsFilename.getBucketName() + "/" + gcsFilename.getObjectName());
ImagesService images = ImagesServiceFactory.getImagesService();
GcsFilename gcsFilename = new GcsFilename(myBucket, myFileName);
BlobstoreService blobstore = BlobstoreServiceFactory.getBlobstoreService();
BlobKey blobKey = blobstore.createGsBlobKey(key);
ServingUrlOptions opts = ServingUrlOptions.Builder.
withBlobKey(blobKey).
secureUrl(true);
images.getServingUrl(opts);
当我执行其中一个代码时,我得到了这个错误:
线程“main”中的异常com.google.apphosting.api.ApiProxy $ CallNotFoundException:找不到API包'blobstore'或调用'CreateEncodedGoogleStorageKey()'。
有什么想法吗?
答案 0 :(得分:0)
@ LaiaxanIV的解决方案发布为问题的编辑:
我发现的解决方案:
String key = ""; // Such as /gs/example-bucket/categories/animals.png" ImagesService images = ImagesServiceFactory.getImagesService(); BlobstoreService blobstore = BlobstoreServiceFactory.getBlobstoreService(); BlobKey blobKey = blobstore.createGsBlobKey(key); ServingUrlOptions opts = ServingUrlOptions.Builder. withBlobKey(blobKey). secureUrl(true); return images.getServingUrl(opts);