Retrieve only file from GET folder request to Box.com

柔情痞子 提交于 2019-12-11 16:33:19

问题


I need retrieve only file from a GET request to Box.com.

Problem is the follow... I have a Panel where I show the files contents in a folder.
Currently I get all the content and I keep only the elements that have type equals to "file".

Now I need to paginate the results. I use the Box API to get an offset of result, in this way:

GET https://api.box.com/2.0/folders/0/items?limit=2&offset=1
Authorization: Bearer MY_TOKEN

I ask for the fist 2 elements. But is obviously that if the first 2 elements is both folder, my panel will show zero elements.

Is there a way to make a GET request specifying the type of the elements? something like this:

GET https://api.box.com/2.0/folders/0/items?limit=2&offset=1&type=file
Authorization: Bearer MY_TOKEN

回答1:


You'll want to probably use the Search API: http://developers.box.com/docs/#search

It lets you specify type=file and get only files. However it goes into all the sub-directories recursively, so it may not provide exactly what you are looking for. If you are looking for only the top-level directory and files-only, then you'll have to do the filtering on your side after the API response. Use GET ./folders//items and paginate through all the items, throwing away all the type=folders items.



来源:https://stackoverflow.com/questions/23953355/retrieve-only-file-from-get-folder-request-to-box-com

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