We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.
Forum Discussion
trithanhnguyen
3 years agoHelpful | Level 6
dbxClient.files().listFolder("") only returns 1 folder
I want to list all the files under my member ID. I use the following code and it only show 1 folder even though I have 8 folders starting from root.
DbxClientV2 dbxClient = dbxTeamClient.asMember(teamMemberId);
ListFolderResult fileRes = dbxClient.files().listFolder("");
List<Metadata> folders = fileRes.getEntries();
String metaDataCursor = fileRes.getCursor();
while (true)
{
for (Metadata metadata : folders)
{
String type;
String details;
if (metadata instanceof FileMetadata)
{
FileMetadata fileMetadata = (FileMetadata) metadata;
type = "file";
details = "(rev=" + fileMetadata.getRev() + ")";
}
else if (metadata instanceof FolderMetadata)
{
FolderMetadata folderMetadata = (FolderMetadata) metadata;
type = "folder";
details = folderMetadata.getSharingInfo() != null ? "(shared)" : "";
}
else if (metadata instanceof DeletedMetadata)
{
type = "deleted";
details = "";
}
else
{
throw new IllegalStateException("Unrecognized metadata type: " + metadata.getClass());
}
System.out.printf("\t%10s %24s \"%s\"\n", type, details, metadata.getPathLower());
}
if (!fileRes.getHasMore())
{
break;
}
// update cursor to fetch remaining results
fileRes = dbxClient.files().listFolderContinue(metaDataCursor);
folders = fileRes.getEntries();
metaDataCursor = fileRes.getCursor();
}
I then changed my code as the following then it shows the first folder and all the folder and files from that branch but the left 7 folder are not show at all. Any suggestiong to fix it?
TThank you.
DbxClientV2 dbxClient = dbxTeamClient.asMember(teamMemberId);
ListFolderBuilder builder = dbxClient.files().listFolderBuilder("");
builder.withRecursive(true);
ListFolderResult fileRes = builder.start();
trithanhnguyen wrote:... Do I need to do some extra setup to list all 3 folders. Thanks.
In all cases you need to set your root to appropriate one using withPathRoot in addition to asMember, if desired folders reside in out of your account's user/member home (as seems it is).
- ЗдравкоLegendary | Level 20
trithanhnguyen wrote:I want to list all the files under my member ID. I use the following code and it only show 1 folder even though I have 8 folders starting from root.
...
You are listing all files in your user/member home folder (recursive eventually). If your rest folders are team folders/spaces then you need to enumerate your root. On personal accounts root matches home, but on business account home is only part on all root content!
Hope this gives direction.
- trithanhnguyenHelpful | Level 6
From 8 folders I have in my account, 3 of them I created by myself. So at least the list folder API should return that 3 folders, but it did not. Do I need to do some extra setup to list all 3 folders. Thanks.
- ЗдравкоLegendary | Level 20
trithanhnguyen wrote:... Do I need to do some extra setup to list all 3 folders. Thanks.
In all cases you need to set your root to appropriate one using withPathRoot in addition to asMember, if desired folders reside in out of your account's user/member home (as seems it is).
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,877 PostsLatest Activity: 12 months 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!