Get all files in box account

爷,独闯天下 提交于 2020-01-24 20:49:25

问题


I need to fetch a list of all the files in a user's box account, such that the list of files can then be displayed in a table view (iOS).

I have successfully implemented this by recursively using /folders/{folder id}/items on all the folder's in my user's box.

However, while this works, it's kind of dirty, seeing as how a request is made for each of the users's folders, which could be quite a large number.

Is there any way to get a list of all the files (it's no issue if folders are included, I can ignore those manually) available?

I tried implementing this using search, but I couldn't identify a value for the query parameter that returned everything.

Any help would be appreciated.

Help me, Obi-Wan Kenobi. You're my only hope.


回答1:


What you are looking for (recursive call through a Box account) is not available. We have enterprise customers will bajillions of files and millions of folders. Recursively asking for everything would take too long.

What we generally recommend is that you ask for as little as you can, and that you use multiple threads and anticipate what you'll need just a little bit, so that you can deliver a high-performance user-interface to your end-users.

For example ?fields=item_collection is expensive to retrieve, and can add a lot to a paylaod. It can double, or 10x the time that it takes to get back a payload from the Box API. Most UI's don't need to show all the items inside every folder. So they are better off asking for ?fields=.

You can make your application responsive to the user if you make the smallest possible call. Of course there is a balance. Mobile networks have high latency, and sometimes that next API call to show some extra thing is slow. But for a folder tree, you can get high performance by retrieving only the current level, displaying that, and then starting to fetch one-level down while the user is looking at the first level.

Same goes for displaying thumbnails. If a user drills into a folder and starts looking at thumbnails for pictures, there's a good chance they'll want to see other thumbnails in that same folder. Your app should anticipate that, and start to pull one or two extras down in the background. Yes, it means more API calls, but your users will give your app a higher rating for being fast.



来源:https://stackoverflow.com/questions/26107389/get-all-files-in-box-account

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