问题
My code is as follows:
requestObj.addField(BoxFolder.FIELD_SIZE);
BoxCollection itemCollection = client.getFoldersManager().getFolderItems(file.getId(),
(BoxFolderRequestObject) requestObj);
List<BoxTypedObject> objects = itemCollection.getEntries();
for (BoxTypedObject innerFile : objects) {
System.out.println("=============" + innerFile.getExtraData(BoxFolder.FIELD_SIZE));
System.out.println("=============" + innerFile.getValue(BoxFolder.FIELD_SIZE));
}
It returns null in both System.out
I looked at BoxTypedObject which does not have a way to return file size.
I do see getSize() in BoxItem but that is not returned by Box.getFolderItems ---> BoxCollection ----> BoxTypedObject
Please provide a way to get Box file size
More Context:
https://github.com/box/box-java-sdk-v2/issues/58
回答1:
BoxTypedObject can be various types. You could do this: if (innerFile instanceof BoxItem) { size = ((BoxItem) innerFile).getSize(); }
来源:https://stackoverflow.com/questions/20616200/getting-file-size-for-box-files-retrieved-via-box-search