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
sdas
8 years agoExplorer | Level 3
How to implement loadedFile method in API V2
Here is my code , how to convert this into API v2 compitable methods.
-(void)prepareForRecoverDB{
if(![Utility isNetworkAvailable]) {
[Utility showAlertViewWithTitle:@"Error!...
- 8 years ago
If you're using the API v2 Objective-C SDK (which is recommended), the equivalent of the loadFile method would be any of the download methods.
You can find a sample of calling those here:
https://github.com/dropbox/dropbox-sdk-obj-c#download-style-request
As well as in the example app:
sdas
Explorer | Level 3
Hi, Greg
while i am downloading the file path of sqlite database , it's actually returing nil and in error part it showing :-
DropboxHttpError[{ ErrorContent = "path/not_found/.."; RequestId = 9c2085907ba4e2bda71a08d96d62af8b; StatusCode = 409; UserMessage = nil; }];
This is my code for downloading data from sqlite data path -----
-(void)prepareForRecoverDataBase { if(![Utility isNetworkAvailable]) { [Utility showAlertViewWithTitle:@"Error!" Message:@"Unable to connect to the host. Please check your network connection." CancelTitle:@"OK"]; return; } [self showLoadingView]; // NSString *filename = [self.arrOfBackupFiles objectAtIndex:self.indexPath_.row]; DBFILESFileMetadata *fileMetadata= [self.arrOfBackupFiles objectAtIndex:self.indexPath_.row]; AppDelegate_Shared *appDelegate = (AppDelegate_Shared *)[UIApplication sharedApplication].delegate; NSString *strPath = [appDelegate dbPath]; NSArray *arrPath = [strPath componentsSeparatedByString:@"/"]; NSString *lastPath = [arrPath lastObject]; if([lastPath isEqualToString:fileMetadata.name]){ self.restoredFileName = @"RentTracker.sqlite"; [appDelegate dbPath:self.restoredFileName]; } else { [appDelegate dbPath:fileMetadata.name]; self.restoredFileName=fileMetadata.name; } NSLog(@"currentPath %@",[appDelegate dbPath:fileMetadata.name]); DBUserClient *client = [DBClientsManager authorizedClient]; NSFileManager *fileManager = [NSFileManager defaultManager]; NSURL *outputDirectory = [fileManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask][0]; NSURL *outputUrl = [outputDirectory URLByAppendingPathComponent:fileMetadata.name]; [[[client.filesRoutes downloadUrl:fileMetadata.pathDisplay overwrite:YES destination:outputUrl] setResponseBlock:^(DBFILESFileMetadata *result, DBFILESDownloadError *routeError, DBRequestError *networkError, NSURL *destination) { if (result) { NSLog(@"%@\n", result); NSData *data = [[NSFileManager defaultManager] contentsAtPath:[destination path]]; NSString *dataStr = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding]; NSLog(@"%@\n", dataStr); } else { NSLog(@"%@\n%@\n", routeError, networkError); } }] setProgressBlock:^(int64_t bytesDownloaded, int64_t totalBytesDownloaded, int64_t totalBytesExpectedToDownload) { NSLog(@"%lld\n%lld\n%lld\n", bytesDownloaded, totalBytesDownloaded, totalBytesExpectedToDownload); }]; // [self downloadData:[appDelegate dbPath:fileMetadata.name]]; [self hideLoadingView]; [Utility showAlertViewWithTitle:@"Restored!" Message:@"File Restored Sucessful!" CancelTitle:@"OK"]; // NSFileManager *fm = [NSFileManager defaultManager]; // [fm removeItemAtPath:[appDelegate dbPath] error:nil]; [[NSUserDefaults standardUserDefaults] setValue:self.restoredFileName forKey:kStoreName]; [[NSUserDefaults standardUserDefaults] synchronize]; // appDelegate.managedObjectModel = nil; // appDelegate.managedObjectContext = nil; // appDelegate.persistentStoreCoordinator = nil; [self.navigationController popViewControllerAnimated:YES]; }
sdas
8 years agoExplorer | Level 3
So i thought may be i had mistaken something during uploading the data. Below is the code for uploading the sqlite dataPath to dropbox.
DB Path-
Before adding time stamp
/var/mobile/Containers/Data/Application/6D7A6DDA-45D0-4509-99A5-E635891D9DB9/Documents/RentTracker.sqlite
After adding time stamp
/var/mobile/Containers/Data/Application/AA188B71-1995-42A1-AC39-64AFD024E42A/Documents/RentTracker_IOS_01_02_2017_10_46_58.sqlite
So,what i am doing is , converting the db file path into data format and passing this as an input data [parameter], while in uploadData [parameter], i sent only the file name . Please correct me , if i doing something wrong in code . HELP ME !
Thank You
-(void)BackupData { // [[NSNotificationCenter defaultCenter]postNotificationName:kShowLoading object:self ]; // AppDelegate *Maindelegate = (AppDelegate *)[[UIApplication sharedApplication] delegate]; [MBProgressHUD showHUDAddedTo:self.window animated:YES]; AppDelegate_Shared *appDelegate = (AppDelegate_Shared *)[UIApplication sharedApplication].delegate; NSString *srcpath = [appDelegate dbPath]; // returning the sqlite file path /* Adding time stamp */ NSDateFormatter *formatter = [[NSDateFormatter alloc] init]; [formatter setDateFormat:@"MM_dd_yyyy_hh_mm_ss"]; NSString *dateStr = [formatter stringFromDate:[NSDate date]]; NSString *fileName = [NSString stringWithFormat:@"RentTracker_IOS_%@.sqlite", dateStr]; DBUserClient *client = [DBClientsManager authorizedClient]; NSData *fileData = [srcpath dataUsingEncoding:NSUTF8StringEncoding allowLossyConversion:NO]; // [client.filesRoutes uploadData:@"/" inputData:fileData]; //extra // For overriding on upload DBFILESWriteMode *mode = [[DBFILESWriteMode alloc] initWithOverwrite]; // [NSString stringWithFormat:@"/%@",fileName] [[[client.filesRoutes uploadData: [NSString stringWithFormat:@"/%@",fileName] mode:mode autorename:@(YES) clientModified:nil mute:@(NO) inputData:fileData] setResponseBlock:^(DBFILESFileMetadata *result, DBFILESUploadError *routeError, DBRequestError *networkError) { if (result) { NSLog(@"%@\n", result); NSLog(@"stringPath of the file %@",result.pathDisplay); [[NSUserDefaults standardUserDefaults]setValue:result.pathDisplay forKey:@"path"]; [[NSUserDefaults standardUserDefaults]synchronize]; [MBProgressHUD hideHUDForView:self.window animated:YES]; [Utility showAlertViewWithTitle:@"Backup!" Message:@"Backup was successful" CancelTitle:@"OK"]; [DBClientsManager unlinkAndResetClients]; } else { NSLog(@"%@\n%@\n", routeError, networkError); [MBProgressHUD hideHUDForView:self.window animated:YES]; } }] setProgressBlock:^(int64_t bytesUploaded, int64_t totalBytesUploaded, int64_t totalBytesExpectedToUploaded) { NSLog(@"\n%lld\n%lld\n%lld\n", bytesUploaded, totalBytesUploaded, totalBytesExpectedToUploaded); }]; [formatter release]; formatter = nil; }
About Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.5,919 PostsLatest Activity: 15 hours ago
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 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!