我尝试用Java从Google App Engine中获取存储在Google云端存储中的文件大小,
我试过了:
FileService fileService = FileServiceFactory.getFileService();
AppEngineFile appEngineFile = fileService.getBlobFile(new BlobKey("blob key"));
int size = (int) fileService.stat(appEngineFile).getLength().longValue();
但它正在返回0
答案 0 :(得分:2)
您必须使用BlobInfo.getSize()
:
BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(new BlobKey("blob key"))
Long blobSize = blobInfo.getSize();