Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.
I would like my app to test whether there is already a file at certain path before trying to upload a file to that path.
How could I do that?
I have an array called sortedFiles. Then I have
int i = 0;
do{
NSString *fileName = [NSString stringWithFormat:@"Pace audio/%@", [[sortedFiles objectAtIndex:i] objectForKey: @"path"]];
DBPath *newPath = [[DBPath root]childPath:fileName];
DBFile *file = [[DBFilesystem sharedFilesystem] createFile:newPath error:nil];
if ( ) //and some sort of test here to see if the file already exists at this path
[file writeContentsOfFile:fileName shouldSteal:NO error:nil];
else {
NSLog(@"File already exists");
}
NSLog(@"The number is %d", i);
i++;
}
while (i < sortedFiles.count);
I've been searching the documentation and I can't think of a way to do this. At the moment, I just get an error saying a file already exists, so at least the file isn't being overwritten.
Ideas?
Thanks.
You can use DBFilesystem.fileInfoForPath
:
https://www.dropbox.com/developers/sync/docs/ios#DBFilesystem.fileInfoForPath:error:
You probably want to do that before you do createFile
though.
Thanks and good catch. That worked
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!