cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Folders

Folders

solsupp
Explorer | Level 3

I am surrently using:

 

 Private Shared Sub FileUploadToDropbox(ByVal filePath As String, ByVal fileName As String, ByVal fileSource As String)
        Dim dbx = New DropboxClient("<REDACTED>")
        Dim fs = New FileStream(fileSource, FileMode.Open, FileAccess.Read)
        Dim updated = dbx.Files.UploadAsync((filePath + ("/" + fileName)), WriteMode.Overwrite.Instance, body:=fs)

End Sub

 

To upload a folder and file.

 

How can I then share this folder with a specific email addres, I wish to then notifiy that email address that a share has been created for them.

14 Replies 14

Greg-DB
Dropbox Staff

To share a folder with a specific Dropbox account using the .NET SDK, you should use ShareFolder to share the folder (once per folder), and then AddFolderMember to invite member(s) to the folder. 

 

By the way, I redacted it from your post, but for the sake of security, you should disable the access token that you posted. You can do so by revoking access to the app entirely, if the access token is for your account, here, or, you can disable just this access token using the API, e.g., using TokenRevoke.

solsupp
Explorer | Level 3

How do I add a member

 

members As IEnumerable(Of AddMember),

Greg-DB
Dropbox Staff

That would look something like this:

 

var members = new[] { new AddMember(new MemberSelector.Email("email@example.com")) };
await this.client.Sharing.AddFolderMemberAsync(sharedFolderId, members);

solsupp
Explorer | Level 3

 Dim myMembers = New AddMember(New MemberSelector.Email("EMAILADDERESS"), Nothing)
        dbx.Sharing.AddFolderMemberAsync((filePath + ("/" + fileName)), myMembers, False, "Docs UPloaded")

 

Seem to get an error, not sure what to do here:


Error BC30512 Option Strict On disallows implicit conversions from 'AddMember' to 'IEnumerable(Of AddMember)'. 

 

Even casting to 'IEnumerable(Of AddMember)' causes error

 

Can you help

Greg-DB
Dropbox Staff

The 'members' parameter does require a IEnumerable<AddMember>, but it appears you're only supplying a AddMember, not in an IEnumerable.

 

I'm not a Visual Basic expert, but I believe you can build it like this:

 

Dim myMembers() as AddMember = {New AddMember(New MemberSelector.Email(emailAddress), Nothing)}

solsupp
Explorer | Level 3

Thanks for that, apologies, I am a newby here, 1 more question, how do I get a folderID, can I quierie it based on folder name?

 

 

Greg-DB
Dropbox Staff

You can get the shared folder ID from SharedFolderMetadata.SharedFolderId (e.g., from a completed ShareFolder job, or elsewhere, such as from ListFolders/ListFoldersContinue) or from FolderSharingInfo.SharedFolderId in FolderMetadata.SharingInfo (e.g., from ListFolder/ListFolderContinue or GetMetadata).

solsupp
Explorer | Level 3

Are there any examples in the API, have googled this, but not sure how to apply this to code.

 

Just want FolderID based on folder name if possible.

   Dim link = dbx.Sharing.GetFolderMetadataAsync((filePath + ("/" + fileName)))
        Dim myMembers() As AddMember = {New AddMember(New MemberSelector.Email("EMAILADDRESS"), Nothing)}
        dbx.Sharing.AddFolderMemberAsync(link.Id.ToString, myMembers, False, "Docs Uploaded")

Get error:

 

System.ArgumentOutOfRangeException: Value should match pattern '\A(?:[-_0-9a-zA-Z:]+)\z' 

Greg-DB
Dropbox Staff

In this code, you're just using 'Id'. You need the 'SharedFolderId'. In your code, that should be something like:

link.SharingInfo.SharedFolderId
Need more support?
Who's talking

Top contributors to this post

  • User avatar
    solsupp Explorer | Level 3
  • User avatar
    Greg-DB Dropbox Staff
What do Dropbox user levels mean?