cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Whether you are transferring a single drive, a team or an entire organization, Movebot's cloud migration tool has been built to make your Dropbox migration simple - learn all about it here.

Discuss Dropbox Developer & API

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

How to assign access level permission while sharing the file to the members

How to assign access level permission while sharing the file to the members

parimisatya
Explorer | Level 3

Hi

How to assign access level permission while sharing the file to the members using API

I have done in c# and code is here.

 

using (var dbx = new DropboxClient(token))
{
var shareFolderLaunch = await dbx.Sharing.ShareFolderAsync("/CloudPOC");

var sharedFolderId = "";
if (shareFolderLaunch.IsAsyncJobId)
{
while (true)
{
var shareFolderJobStatus = await dbx.Sharing.CheckShareJobStatusAsync(shareFolderLaunch.AsAsyncJobId.Value);
if (shareFolderJobStatus.IsFailed)
{
Console.WriteLine("Sharing folder failed: " + shareFolderJobStatus.AsFailed.Value);
return;
}
else if (shareFolderJobStatus.IsInProgress)
{
Console.WriteLine("Sharing folder in progress...");
// todo: add some delay
}
else if (shareFolderJobStatus.IsComplete)
{
Console.WriteLine("Sharing folder complete.");
sharedFolderId = shareFolderJobStatus.AsComplete.Value.SharedFolderId;
break;
}
}
}
else if (shareFolderLaunch.IsComplete)
{
sharedFolderId = shareFolderLaunch.AsComplete.Value.SharedFolderId;
}
else
{
return;
}

Console.WriteLine("Shared folder with ID: " + sharedFolderId);

var members = new[] { new AddMember(new MemberSelector.Email("example@xxx.com")) };
var access_level = "viewer";
var add_message_as_comment = false;
await dbx.Sharing.AddFolderMemberAsync(sharedFolderId, members,true);
}

1 Accepted Solution

Accepted Solutions

Re: How to assign access level permission while sharing the file to the members

Greg-DB
Dropboxer

When adding a member to a shared folder using the AddFolderMemberAsync method in the Dropbox .NET SDK like this, you can set the new member's access level when you construct the AddMember object, using this AddMember constructor, which takes both a MemberSelector and an AccessLevel.

 

The MemberSelector works the way you already have it, and you can supply an instance of the desired AccessLevel. For example, for view-only access, that would be AccessLevel.Viewer.Instance.

View solution in original post

2 Replies 2

Re: How to assign access level permission while sharing the file to the members

Greg-DB
Dropboxer

When adding a member to a shared folder using the AddFolderMemberAsync method in the Dropbox .NET SDK like this, you can set the new member's access level when you construct the AddMember object, using this AddMember constructor, which takes both a MemberSelector and an AccessLevel.

 

The MemberSelector works the way you already have it, and you can supply an instance of the desired AccessLevel. For example, for view-only access, that would be AccessLevel.Viewer.Instance.

Re: How to assign access level permission while sharing the file to the members

parimisatya
Explorer | Level 3

thanks for your prompt response

Who's talking

Top contributors to this post

  • User avatar
    parimisatya Explorer | Level 3
  • User avatar
    Greg-DB Dropboxer
What do Dropbox user levels mean?
Need more support?