I would like to list all files on dropbox using API v2.
Some example with java would be really nice.
Currently I'm doing the following:
public String syncFiles(DbxClientV2 client) throws ListFolderErrorException, DbxException {
ListFolderBuilder listFolderBuilder = client.files().listFolderBuilder("");
ListFolderResult result = listFolderBuilder.withRecursive(true).start();
Logger log = Logger.getLogger("thread");
log.setLevel(Level.INFO);
while (true) {
if (result != null) {
for ( Metadata entry : result.getEntries()) {
if (entry instanceof FileMetadata){
log.info("Added file: "+entry.getPathLower());
}
}
if (!result.getHasMore()) {
log.info("GET LATEST CURSOR");
return result.getCursor();
}
try {
result = client.files().listFolderContinue(result.getCursor());
} catch (DbxException e) {
log.info ("Couldn't get listFolderContinue");
}
}
}
}
This is working but I don't know if it's the best way to list all files on dropbox.