Skip to content

Commit d042fda

Browse files
author
Karl Rieb
committed
Fix tutorial example to properly page through list_folder results.
Fixes T86573.
1 parent 4b6c210 commit d042fda

2 files changed

Lines changed: 13 additions & 3 deletions

File tree

ChangeLog.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
- Fix tutorial example to list folder entries for folders with many files.
12

23
---------------------------------------------
34
2.0.1 (2016-03-09)

examples/tutorial/src/main/java/com/dropbox/core/examples/tutorial/Main.java

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import com.dropbox.core.DbxRequestConfig;
55
import com.dropbox.core.v2.DbxClientV2;
66
import com.dropbox.core.v2.files.FileMetadata;
7+
import com.dropbox.core.v2.files.ListFolderResult;
78
import com.dropbox.core.v2.files.Metadata;
89
import com.dropbox.core.v2.users.FullAccount;
910

@@ -26,9 +27,17 @@ public static void main(String args[]) throws DbxException, IOException {
2627
System.out.println(account.getName().getDisplayName());
2728

2829
// Get files and folder metadata from Dropbox root directory
29-
List<Metadata> entries = client.files().listFolder("").getEntries();
30-
for (Metadata metadata : entries) {
31-
System.out.println(metadata.getPathLower());
30+
ListFolderResult result = client.files().listFolder("");
31+
while (true) {
32+
for (Metadata metadata : result.getEntries()) {
33+
System.out.println(metadata.getPathLower());
34+
}
35+
36+
if (!result.getHasMore()) {
37+
break;
38+
}
39+
40+
result = client.files().listFolderContinue(result.getCursor());
3241
}
3342

3443
// Upload "test.txt" to Dropbox

0 commit comments

Comments
 (0)