cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Tell us what you want to see on the Community here!
Close

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: 

I want to get a list of files in a shared folder using Objective-C SDK

Highlighted

I want to get a list of files in a shared folder using Objective-C SDK

Explorer | Level 3

I'm using Objective-c SDK v2.


I used the initWithAccessToken method of the DBTeamClient class to get an instance of the DBUserClient class.

I used the listFolders method of sharingRoutes of DBUserClient to get the shared folders that exist in the root.

 

But, I don't know how to get the list of files that exist in the obtained shade folder.

It seems that the shade folder cannot be accessed by filesRoutes of DBUserClient.

 

What steps do I need to take to get a list of the files that exist in the shared folder?

 

1 Accepted Solution

Accepted Solutions
Highlighted

Re: I want to get a list of files in a shared folder using Objective-C SDK

Dropboxer

If pathLower is nil, that means that the folder is not "mounted", so it doesn't have a path in that account. I recommend reading the File Access Guide and the Team Files Guide for more information on how these mechanisms work. 

 

For reference, if you need to set the "Dropbox-API-Path-Root" header mentioned there, that's accessible via withPathRoot in the Objective-C SDK.

View solution in original post

6 Replies 6
Highlighted

Re: I want to get a list of files in a shared folder using Objective-C SDK

Dropboxer

You should use DBFILESUserAuthRoutes.listFolder/DBFILESUserAuthRoutes.listFolderContinue to list the contents of any particular folder (shared or not), by specifying the relevant path.

 

For example, when using DBSHARINGUserAuthRoutes.listFolders/DBSHARINGUserAuthRoutes.listFoldersContinue, you can get the path from the relevant DBSHARINGSharedFolderMetadataBase.pathLower returned in DBSHARINGListFoldersResult.entries.

Highlighted

Re: I want to get a list of files in a shared folder using Objective-C SDK

Explorer | Level 3

Thank you Greg-DB.

 

I ran the following source to get DBSHARINGSharedFolderMetadataBase.

The folder shared in the personal folder was able to get the pathLower.

But, the DropBox Business team folder had a pathLower of nil.

 

Is the procedure different for the DropBox Business team folder?

 

DBUserClient *userClient = [teamClient userClientWithMemberId:_MY_MEMBER_ID_];

[[userClient.sharingRoutes listFolders] setResponseBlock:^(DBSHARINGListFoldersResult * _Nullable result, DBNilObject * _Nullable routeError, DBRequestError * _Nullable networkError) { for (DBSHARINGSharedFolderMetadata *entry in result.entries) { if(entry.pathLower==nil){ NSLog(@"pathLower is nil"); }else{ NSLog(entry.pathLower); } } }];
Highlighted

Re: I want to get a list of files in a shared folder using Objective-C SDK

Dropboxer

If pathLower is nil, that means that the folder is not "mounted", so it doesn't have a path in that account. I recommend reading the File Access Guide and the Team Files Guide for more information on how these mechanisms work. 

 

For reference, if you need to set the "Dropbox-API-Path-Root" header mentioned there, that's accessible via withPathRoot in the Objective-C SDK.

View solution in original post

Highlighted

Re: I want to get a list of files in a shared folder using Objective-C SDK

Explorer | Level 3

Thank you Greg-DB.

I was able to access the files in the Dropbox Business team folder.

 

I got a new user client by passing the folder ID of the shared folder to the withPathRoot method of the DBUserClient class.
I am using this new user client to access files in shared folders.

 

The code looks like this.

DBUserClient *userClient = [teamClient userClientWithMemberId:_MY_MEMBER_ID_];
[[userClient.sharingRoutes listFolders]
 setResponseBlock:^(DBSHARINGListFoldersResult * _Nullable result, DBNilObject * _Nullable routeError, DBRequestError * _Nullable networkError) {
    DBSHARINGSharedFolderMetadata *entry = result.entries[0];
    DBCOMMONPathRoot *pathRoot =[[DBCOMMONPathRoot alloc] initWithNamespaceId:entry.sharedFolderId];
    workUserClient =  [userClient withPathRoot:pathRoot];
    [[workUserClient.filesRoutes listFolder:path]
     setResponseBlock:^(DBFILESListFolderResult *result, DBFILESListFolderError *routeError, DBRequestError *error) {
        if (result)
        {
             ...
        }
    }];
}];

Please point out any mistakes.

Highlighted

Re: I want to get a list of files in a shared folder using Objective-C SDK

Dropboxer

Note that you should always implement listFolderContinue in addition to listFolder to be sure you get the full listing.

Highlighted

Re: I want to get a list of files in a shared folder using Objective-C SDK

Explorer | Level 3

I recognized it.

Thank you for your support.

Work Smarter with Dropbox

The way we work is changing. Share and discover new ways to work smarter with Dropbox in our community.

Sound good? Let's get started.
Who's talking

Top contributors to this post

What do Dropbox user levels mean?
Need more support?