问题
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