Collectives™ on Stack Overflow

Find centralized, trusted content and collaborate around the technologies you use most.

Learn more about Collectives

Teams

Q&A for work

Connect and share knowledge within a single location that is structured and easy to search.

Learn more about Teams

I'm trying to get a list of all my files in box, and I don't want to go over each and every folder and extract the files, it takes too much time if I have lots of files. So what I came up with is using the search method over the root folder using the query "0 1 2 3 4 5 6 7 8 9". The reason I use this query is that the search method also search the file ID, and every files ID must contain one of these numbers.

My problem is that I get maximum 200 results, while I have much more files in my box account. I'm using the Java SDK, if I use the REST api I can use limit and offset, but in the Java SDK I don't have such option. I have also tried using an iterator but it still came up only with 200 results.

Any ideas?

This is my code:

BoxFolder folder = new BoxFolder(api, "0");
    Iterable<BoxItem.Info> results = folder.search("0 1 2 3 4 5 6 7 8 9");
    int i = 1;
    for (BoxItem.Info result : results) {
        // Do something with the search result.
        System.out.println(i + ") " + result.getName());

The iterator should be handling paging for you automatically, which is why there isn't a way of manually specifying the offset. If you're getting more results when using the REST API directly, then there might be a bug. If so, could you file an issue on GitHub.

I should also mention that search isn't a very reliable way of getting all the items in your account. File IDs aren't guaranteed to always be numbers, and indexing delays means that new items don't show up in search results right away.

So the best way to list all of the files is recursively going over each and every folder and list its items? The problem is its takes way too much time, around 3 minutes for 1000 files+-. Isn't there a way to make it faster? Also, if ID aren't always numbers, what other char it might contain? Thanks! – Itai Soudry Jun 10, 2015 at 6:23

Thanks for contributing an answer to Stack Overflow!

  • Please be sure to answer the question. Provide details and share your research!

But avoid

  • Asking for help, clarification, or responding to other answers.
  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.