cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

List all files on dropbox using API v2

List all files on dropbox using API v2

Lechucico
Helpful | Level 6
Go to solution

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.

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution
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.

View solution in original post

1 Reply 1

Greg-DB
Dropbox Staff
Go to solution
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.
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?