We’re Still Here to Help (Even Over the Holidays!) - find out more here.
Forum Discussion
Nenciu D.
11 years agoNew member | Level 1
Check if folder exists and collect shared folder
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) { ...
Nenciu D.
11 years agoNew member | Level 1
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.
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
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, Facebook or Instagram.
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!