2016-09-03 4 views
2

GAE를 사용하는 프로젝트에이 코드를 쓰고 있습니다. Blobstore를 사용하지 않지만 serveUrl 메서드를 사용해야합니다.GoogleCloudStorage에서 BlobstoreKey 만들기

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); 

나는이 오류가이 코드, 메신저 중 하나를 실행합니다

Exception in thread "main" com.google.apphosting.api.ApiProxy$CallNotFoundException: The API package 'blobstore' or call 'CreateEncodedGoogleStorageKey()' was not found.

어떤 생각을?

SOLUTION I FOUND:

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); 
+0

당신의 코드 라인이 예외를 throw : LaiaxanIV의 솔루션 @ –

+0

@LaiaxanIV이 문제에 대한 해결책이 있습니까? 그렇다면 공유하십시오. 같은 문제에 직면 해 있습니다. – das

+0

@das 네, 제 질문을 편집했습니다 – LaiaxanIV

답변

0

는 질문에 편집으로 게시?
+0

오, 나는 그것을 몰랐다. 감사! – LaiaxanIV