You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Lechucico
8 years agoHelpful | Level 6
List all files on dropbox using API v2
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.
- Calling listFolder with "" to identify root, with recursive=true, and calling back to listFolderContinue as necessary like this is the correct way to list all of the files.
- Greg-DBDropbox StaffCalling listFolder with "" to identify root, with recursive=true, and calling back to listFolderContinue as necessary like this is the correct way to list all of the files.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,910 PostsLatest Activity: 3 days agoIf you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.
For more info on available support options for your Dropbox plan, see this article.
If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!