问题
The files/list _folders method in api docs has the following for the description of the cursor parameter:
cursor - Pass the cursor into list_folder/continue to see what's changed in the folder since your previous query.
has_more - If true, then there are more entries available. Pass the cursor to list_folder/continue to retrieve the rest.
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder
Which is it then? If I make another request to list_folders_continue passing in the token, am I requesting another page of results or changes to the folder? If I am requesting another page of results, what is the limit that was applied? And can I control that?
The docs also have the list_folder method under sharing, which appears to have more precise definition of the cursor and the support for the limit parameter https://www.dropbox.com/developers/documentation/http/documentation#sharing-list_folders
Will the method under files have that too?
回答1:
Which is it then? If I make another request to list_folders_continue passing in the token, am I requesting another page of results or changes to the folder?
It's both. The /files/list_folder/continue endpoint is used both for returning additional pages of items, as well as getting further updates in the future.
Each page returned by /files/list_folder[/continue] is limited in size, but there is no guaranteed limit, nor can you control that limit. Your app should just always check has_more
and call back to /files/list_folder/continue if it is true
.
Also, the endpoints /files/list_folder and /sharing/list_folders are different endpoints with different functionality.
The /files/list_folder endpoint is documented as:
Returns the contents of a folder.
The /sharing/list_folders endpoint is documented as:
Return the list of all shared folders the current user has access to.
The two endpoints use different cursors, for use with /files/list_folder/continue and /sharing/list_folders/continue, respectively.
回答2:
Which is it then? If I make another request to list_folders_continue passing in the token, am I requesting another page of results or changes to the folder? If I am requesting another page of results, what is the limit that was applied? And can I control that?
My own trial and error experimentation has determined that the "It's both" answer posted by Greg is not correct. Specifically, the correct answer is "it's either". See below for more details.
When you call files/list_folder
and it returns the entire list of contents (with a has_more
value of false
), then the cursor returned is suitable for monitoring subsequent changes to the path specified by passing that cursor to files/list_folder/continue
.
If files/list_folder
returns the first of multiple pages of contents (with a has_more
value of true
), then the cursor returned is suitable for getting the next page of contents by passing it to files/list_folder/continue
. This cursor is not suitable for monitoring for changes (try it yourself, you can call continue as many times as you want with that cursor and you will always get the second page of contents).
It's not entirely clear from the docs, but when getting pages of contents from files/list_folder/continue
, each call will return a new cursor, and that new cursor must be passed to a subsequent call to files/list_folder/continue
in order to get the next page. You must chain the cursors together in this way until you get the last page (where has_more
is false
).
The cursor returned in that last call to files/list_folder/continue
can then be used in subsequent calls to files/list_folder/continue
to monitor for changes to the original path specified in the very first call to files/list_folder
.
So the cursor is either suitable for monitoring for changes (when it is returned with a has_more
value of false
) OR it is suitable for getting a subsequent page of contents (when it is returned with a has_more
value of true
), regardless of whether the call that produced the cursor was files/list_folder
or files/list_folder/continue
, but it is never both.
来源:https://stackoverflow.com/questions/38483875/dropbox-api-v2-confusion-with-cursor-and-paging-for-list-folders