Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
367 views
in Technique[技术] by (71.8m points)

rest - Retrieve only file from GET folder request to Box.com

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
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...