Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
Hello,
1.I'm trying to check if folder exist in my dropbox by retrieving metadata from given path: (example path "/myfolder")
public async Task<Metadata> GetFolderMetadata(string folderPath)
{
Metadata folderMetadata = await client.Files.GetMetadataAsync(folderPath);
if (folderMetadata != null)
return folderMetadata;
return null;
}
This is my method ,but if path doesn't exist , my application crashes without any error message.
2.Also I want to collect all shared folders and then to retrieve the users(their emails only) that are sharing that folders.
I'm using sdk v2 for C#.
Thank you
I believe you'll need to wrap the call in a try/catch so you can handle the exception when the path doesn't exist.
For your second question, this isn't possible in the API today. (The email addresses of members of a shared folder are not exposed.)
Thank you again Steve , you are great . So my solution for the first question was something like this:
private bool CheckIfCloudPathExists(string cloudPath)
{
Metadata metadata = new Metadata();
try
{
System.Threading.Tasks.Task<Metadata> taskUpload = Task.Run(() => GetFolderMetadata(cloudPath));
if (taskUpload.Result != null)
metadata = taskUpload.Result;
}
catch (AggregateException e)
{
if (e != null && e.InnerException != null && e.InnerException is ApiException<GetMetadataError>)
{
GetMetadataError err = (e.InnerException as ApiException<GetMetadataError>).ErrorResponse;
if (err.IsNotFound || err.IsOther)
return false;
}
}
return metadata != null;
}
I will reformulate the second question : Is it possible to set permisions to a file like this :
File cloudFile = GetCloudFile(CloudPath); //here I'm getting my file ,and then I set it's permissions
if (cloudFile == null)
return false;
Permission newPermission = new Permission();
newPermission.Value = UserEmail;
newPermission.Type = "user";
if ( PermissionType == 1 )
newPermission.Role = "reader";
else if (PermissionType == 2)
newPermission.Role = "writer";
try
{
PermissionsResource.InsertRequest insertRequest = GoogleDriveService.Permissions.Insert(newPermission, cloudFile.Id);
if (NotifyUserByEmail == false && UserEmail.EndsWith("@google.com"))
insertRequest.SendNotificationEmails = true;
else
insertRequest.SendNotificationEmails = NotifyUserByEmail;
if (!string.IsNullOrEmpty(OptionalEmailMessage))
insertRequest.EmailMessage = OptionalEmailMessage;
var retVal = insertRequest.Execute();
}
This example is made on google api . When I want to share a file , I set it's permissions.
Dropbox doesn't have a permission model that looks like that. In Dropbox, you can create a share link for a file or folder (which can then be used by anyone who has that URL to read the contents of the file or folder), or you can share a folder (which gives specific users access to that folder in their own Dropbox).
Currently, the API only supports share links. So you can get a link for a file and then send that link to people you want to grant (read-only) access to.
The Share Folder button method or Send link method for a file are implemented? Because I want to at least send a notification through email .
The SDK enables you to get a shared link for a file or folder, e.g., using CreateSharedLinkAsync.
It doesn't currently offer the ability to create shared folders though, as Steve mentioned.
In any case, it's not currently possible to make Dropbox send an email about it for you via the API, but I'll be sure to pass this along as a feature request.
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!