Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
okay i start from scratch "again", how i can share file and folder via dropbox api, i think some sharing flow,
1. get the file and folder id, ( i already try it, show just two digit number)
2. choose the folder to share by adding member ( using id but i'm not sure the metadata.id.tostring give the right id)
3. what i shoul do next ?
step 1
using get_metadata -> should i call sharedfolderasync ? -> what next ? -> using addfoldermember -> done ?
step 2
using get_metadata -> addfoldermember -> done
betwen step 1 or 2 , which one is right ?
To share a folder, you should first call ShareFolderAsync. That takes a "path" parameter that should be the path to the folder that you want to share. The documentation explains how to check the result of that operation.
Once that's done, you should then call AddFolderMemberAsync to invite members to that shared folder. That takes the shared folder ID, from the first step above, as well as the list of members you want to invite (a list of AddMember instances).
That would look something like this:
var shareFolderLaunch = await this.client.Sharing.ShareFolderAsync ("/folder_to_share"); var sharedFolderId = ""; if (shareFolderLaunch.IsAsyncJobId) { while (true) { var shareFolderJobStatus = await this.client.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("email@example.com")) }; await this.client.Sharing.AddFolderMemberAsync(sharedFolderId, members);
hey @Greg , thanks for the code now i able to share a folder, but i think the next step is to mount the folder at the added member, i want to do it automaticly from sharing can i ?
Yes, as long as you're authorized as the receiving user you can use MountFolderAsync to mount the shared folder in their account.
okay, i get it but how to get the share id is it the same way like we share the folder or i just need to use asyncidjob is complete ?, and why when i try to share file "add member selector "method that you gave to me is not working, its always return with null. and how to change its level of acces
this my code
Private Async Sub ShareFileToolStripMenuItem_Click(sender As Object, e As EventArgs) Handles ShareFileToolStripMenuItem.Click For Each C As ListViewItem In listfile.SelectedItems Dim sharefile = A.Sharing.GetFileMetadataAsync(direktori.Text & "/" & C.Text) Dim sharefileid = sharefile.Result.Id MessageBox.Show(sharefileid) Dim member = {New AddMember(New MemberSelector.Email("vincencia.ratna@gmail.com"))} Await A.Sharing.AddFileMemberAsync(file:=sharefileid, members:=member) Next End Sub
and the next question is how we change folder member policy ?
The MountFolderAsync method takes a shared folder ID, which is the same as the sharedFolderId value from my code sample.
You can also use ListMountableFoldersAsync/ListMountableFoldersContinueAsync to list the folders available to mount in an account.
Your latest sample instead seems to just be getting the ID of a file, not a shared folder ID. Also, it appears you're trying to use AddFileMemberAsync, which is different from AddFolderMemberAsync anyway.
The AddFileMemberAsync method does take a file path or ID. Here's a sample for AddFileMemberAsync that works for me:
var members = new[] { new MemberSelector.Email("email@example.com") }; await client.Sharing.AddFileMemberAsync ("/test.txt", members);
What specifically wasn't working for you? One thing I notice that may be a problem in your code is that you're building an array of AddMember, but AddFileMemberAsync just takes an array of MemberSelector.
okay greg, your code work, now my problem is why i cant share mp3 ? , are there some file format that dropbox api doesnt support to share ?, and now i stil try to show the list of mountable folder, and mount it as reciever. i confuse how to retrieve the list. this is the las feature of my basic dropbox vb application, i interested to upgrade my application further with more robust API.
now the question is
1. what file extension dropbox support to add member beside txt ?
2. how to get the list of mountable folder -> get the share id -> and mount it
1) The file extension doesn't matter. You can share any file type. Are you getting an error when trying to share a different file?
2) You can use ListMountableFoldersAsync/ListMountableFoldersContinueAsync to list the folders available to mount in an account. You can then use MountFolderAsync to mount folders using the returned SharedFolderMetadata.SharedFolderId.
Hi there!
If you need more help you can view your support options (expected response time for a 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!