getting file size for box files retrieved via box

2019-08-08 10:41发布

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

标签: box-api
1条回答
仙女界的扛把子
2楼-- · 2019-08-08 11:15

BoxTypedObject can be various types. You could do this: if (innerFile instanceof BoxItem) { size = ((BoxItem) innerFile).getSize(); }

查看更多
登录 后发表回答