【问题标题】:GAE Blob Store get file sizeGAE Blob Store 获取文件大小
【发布时间】:2013-02-11 02:59:14
【问题描述】:

我尝试从 Java 中的 Google App Engine 获取存储在 Google Cloud Storage 中的文件的大小,

我试过了:

FileService fileService = FileServiceFactory.getFileService();
AppEngineFile appEngineFile = fileService.getBlobFile(new BlobKey("blob key"));
int size = (int) fileService.stat(appEngineFile).getLength().longValue();

但它返回 0

【问题讨论】:

    标签: java google-app-engine blobstore google-cloud-storage


    【解决方案1】:

    你必须使用BlobInfo.getSize():

    BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
    BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(new BlobKey("blob key"))
    Long blobSize = blobInfo.getSize();
    

    【讨论】:

      猜你喜欢
      • 2014-10-06
      • 1970-01-01
      • 2014-09-04
      • 2021-06-13
      • 2018-05-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-16
      相关资源
      最近更新 更多