My app shows dropbox files, and the documents directory. when viewing dropbox files i can press a button that shows a list of all my document folders, and subdirectories in those folders so they can chose the folder they want to put that file in the documents. when doing this i used dropbox's objective c API they say to use in the documentation to download a file into a path on the system.
NSString *DocumentsPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES) objectAtIndex:0];
for (NSIndexPath *indexPath in [dropboxFilesTable indexPathsForSelectedRows]) {
DBMetadata *fileMetadata = [[dropboxFolderMetadata contents] objectAtIndex:indexPath.row];
[[self restClient] loadFile:fileMetadata.path intoPath:DocumentsPath];
}
the delegate for the dropbox says it is successfully put inside, but when i went back in, every folder and downloaded file has been deleted and that file is still not in the folder. i thought it would need the final path like "path to documents"/"filename", but then dropbox gives a error for that. Anyone know why its deleting all my files and not putting it in my documents?
The intoPath
parameter needs to be a full filename path, not a directory. You need to update the last line to something like:
NSString *filename = [fileMetadata.path lastPathComponent];
NSString *destPath = [DocumentsPath stringByAppendingPathComponent:filename];
[[self restClient] loadFile:fileMetadata.path intoPath:destPath];
Also make sure that you are only doing this will files and not folders.