We Want to Hear From You! What Do You Want to See on the Community? Tell us here!
Forum Discussion
solsupp
7 years agoExplorer | Level 3
Folders
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
- Greg-DB7 years ago
Dropbox Community Moderator
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.
- solsupp7 years agoExplorer | Level 3
How do I add a member
members As IEnumerable(Of AddMember),
- Greg-DB7 years ago
Dropbox Community Moderator
That would look something like this:
var members = new[] { new AddMember(new MemberSelector.Email("email@example.com")) }; await this.client.Sharing.AddFolderMemberAsync(sharedFolderId, members);
- solsupp7 years agoExplorer | 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-DB7 years ago
Dropbox Community Moderator
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)}
- solsupp7 years agoExplorer | 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-DB7 years ago
Dropbox Community Moderator
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).
- solsupp7 years agoExplorer | 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-DB7 years ago
Dropbox Community Moderator
In this code, you're just using 'Id'. You need the 'SharedFolderId'. In your code, that should be something like:
link.SharingInfo.SharedFolderId
- solsupp7 years agoExplorer | Level 3
link.SharingInfo.SharedFolderId not available in LINK, only have link.id available
Dim link = dbx.Files.ListFolderAsync(filePath + ("/" + fileName)) - Is this correct
I am worndering if I am going about this the wrong way, What if I have no sharing on a folder?
I want to share the above folder, if its not shared, will sharedfolderID be null.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,037 PostsLatest Activity: 9 hours ago
The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.
If 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!