问题
Is it possible to check for differences between local and Dropbox?
Hello. I am currently working on a simple gallery App which displays all Dropbox images.
The workflow so far: I log into Dropbox. The App scans recursively through all Dropbox folders and checks for images, then takes the metadata and displays the images.
Now I want to know if it is possible to check for differences so the App does not need to run through all folders every time but only if something has changed (for example if new images have been added to a Dropbox folder).
Thank you in advance.
回答1:
The best way to keep track of changes in a Dropbox account when using the Dropbox API is by using /2/files/list_folder and /2/files/list_folder/continue:
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-continue
You should store the latest returned cursor, and then call back to /2/files/list_folder/continue using that cursor. It will returned only the changes since you last called.
For client-side apps, you can use /2/files/list_folder/longpoll to efficiently know when there are changes to retrieve:
https://www.dropbox.com/developers/documentation/http/documentation#files-list_folder-longpoll
There are also corresponding methods if you're using an SDK. For example, in the Dropbox Java SDK for API v2, these are listFolder, listFolderContinue, and listFolderLongpoll, respectively.
来源:https://stackoverflow.com/questions/40044326/android-dropbox-check-for-differences