通过GCS提供文件时找不到blob错误

时间:2013-08-26 18:36:26

标签: google-app-engine servlets google-cloud-storage

我正在尝试通过Blob提供zip文件,存储在GCS中。但我收到此错误“严重:无法找到blob:BlobKey:encoded_gs_key:XYZ”

我还尝试了此链接中的给定代码,以确保我在对象上拥有正确的ACL,并且我已成功运行此代码:https://developers.google.com/appengine/docs/java/googlecloudstorageclient/migrate

  java.io.PrintWriter out = resp.getWriter( );

    out.println("before");

    try{
                GcsFilename fileName = getFileName();
                BlobstoreService blobstoreService = BlobstoreServiceFactory.getBlobstoreService();
                out.println("after");
                BlobKey blobKey = blobstoreService.createGsBlobKey(
                    "/gs/"+ fileName.getBucketName() + "/" + fileName.getObjectName());
                out.println("before");
                out.println(blobKey);
                blobstoreService.serve(blobKey, resp);
    }
    catch(Exception e){

         out.println(e.getMessage());

    }
           resp.setContentType("application/zip");
           resp.getWriter().println("Hello, world Blob");


}

private GcsFilename getFileName() {

    String bucketname = "androidbucket";
    String filename = "test.zip";
    return new GcsFilename(bucketname, filename);
  }

在这里帮助我!!任何帮助表示赞赏!!

0 个答案:

没有答案