getting file size for box files retrieved via box search

大兔子大兔子 提交于 2020-01-16 00:54:10

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!