Java GAE Blob存储获取文件大小
我试图从Java版的Google App Engine获取存储在Google云存储中的文件大小 我试过这个:Java GAE Blob存储获取文件大小,java,google-app-engine,blobstore,google-cloud-storage,Java,Google App Engine,Blobstore,Google Cloud Storage,我试图从Java版的Google App Engine获取存储在Google云存储中的文件大小 我试过这个: FileService fileService = FileServiceFactory.getFileService(); AppEngineFile appEngineFile = fileService.getBlobFile(new BlobKey("blob key")); int size = (int) fileService.stat(appEngineFile).get
FileService fileService = FileServiceFactory.getFileService();
AppEngineFile appEngineFile = fileService.getBlobFile(new BlobKey("blob key"));
int size = (int) fileService.stat(appEngineFile).getLength().longValue();
但是它返回0您必须使用:
BlobInfoFactory blobInfoFactory = new BlobInfoFactory();
BlobInfo blobInfo = blobInfoFactory.loadBlobInfo(new BlobKey("blob key"))
Long blobSize = blobInfo.getSize();