You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.
Forum Discussion
Robert S.138
9 years agoHelpful | Level 7
Creating a folder that already exists (iOS)
I went through this already for Android, and I learned that to create a folder that might already exists I only need to check the exception as follows:
catch (CreateFolderErrorException err) { if(...
- 9 years ago
In this case, you'd get a DBFILESCreateFolderError in your cfError variable, containing a "conflict" DBFILESWriteError in the path field.
Here's an example of how you'd detect the different error cases, picking out the conflict error:
[[client.filesRoutes createFolder:@"/testfolder"] response:^(DBFILESFolderMetadata *result, DBFILESCreateFolderError *cfError, DBError *error) {
if (result) {
NSLog(@"Create folder succeeded:");
NSLog(@"%@", result);
} else {
NSLog(@"Create folder failed:");
if (cfError) {
NSLog(@"The error is a create folder error.");
if ([cfError isPath]) {
NSLog(@"The error is a path error.");
if (cfError.path.isConflict) {
NSLog(@"Couldn't create folder because there was something in the way.");
} else {
NSLog(@"Other create folder path error:");
NSLog(@"%@", cfError.path);
}
}
} else if (error) {
NSLog(@"The error is a generic error.");
NSLog(@"%@", error);
}
}
}];(Apologies for the poor formatting.)
Greg-DB
9 years agoDropbox Staff
That would also be a path conflict error. The conflict error itself just means that something is already at the path. You can then check that DBFILESWriteConflictError to see if it was a file or folder, e.g. to expand on my last example:
[[client.filesRoutes createFolder:@"/testfolder"] response:^(DBFILESFolderMetadata *result, DBFILESCreateFolderError *cfError, DBError *error) {
if (result) {
NSLog(@"Create folder succeeded:");
NSLog(@"%@", result);
} else {
NSLog(@"Create folder failed:");
if (cfError) {
NSLog(@"The error is a create folder error.");
if ([cfError isPath]) {
NSLog(@"The error is a path error.");
if (cfError.path.isConflict) {
NSLog(@"Couldn't create folder because there was something in the way.");
if (cfError.path.conflict.isFolder) {
NSLog(@"Couldn't create folder because a folder already exists there.");
} else if (cfError.path.conflict.isFile) {
NSLog(@"Couldn't create folder because a file already exists there.");
} else {
NSLog(@"Other create folder path conflict error:");
NSLog(@"%@", cfError.path.conflict);
}
} else {
NSLog(@"Other create folder path error:");
NSLog(@"%@", cfError.path);
}
}
} else if (error) {
NSLog(@"The error is a generic error.");
NSLog(@"%@", error);
}
}
}];
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
5,889 PostsLatest Activity: 6 hours agoIf 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!