Reputation: 1741
Using below code to upload file to dropbox, only change i made is to replace the file on dropbox server. But since then faced this problem for the first time got this warning in console only and not traceable in code but when user tries again it works. Can anyone guide why this happens?
-(void)uploadToDropbox
{
NSLog(@"Upload to dropbox from local DB");
if ([[DBSession sharedSession] isLinked])
{
StartLoadingIndicator:self];
[self addLoadingView];
BOOL success;
NSFileManager *fileManager = [NSFileManager defaultManager];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *localPath=[documentsDirectory stringByAppendingPathComponent:@"/MyApp/MyApp.sqlite"];
success =[fileManager fileExistsAtPath:localPath];
if (success)
{
NSLog(@"DBX_Path %@",[NSString stringWithFormat:@"%@",[[NSUserDefaults standardUserDefaults] valueForKey:@"DBX_Path"]]);
}
else
{
NSLog(@"Not exist");
}
}
else
{
UIAlertView *Sessionalert=[[UIAlertView alloc]initWithTitle:@"You need to login first with valid credentials." message:nil delegate:self cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[Sessionalert show];
Sessionalert=nil;
}
}
- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata
{
NSLog(@"metadata:%@", metadata);
NSEnumerator *e= [metadata.contents objectEnumerator];
DBMetadata *dbObject;
//NSUInteger numberOfFiles = [metadata.contents count];
while ((dbObject = [e nextObject])) {
if (!dbObject.isDirectory) {
NSString *fileName = [dbObject.path lastPathComponent];
if (![fileName isEqualToString:@"MyApp.sqlite"]) {
/* call dbupload if dbObject.lastModifiedDate > than your local file*/
revName = nil;
}
else{
revName = [dbObject.rev lastPathComponent];
NSLog(@"revName:%@", revName);
}
}
}
NSString *filename = @"MyApp.sqlite";
NSString *destDir = @"/";
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *localPath=[documentsDirectory stringByAppendingPathComponent:@"/MyApp/MyApp.sqlite"];
[[self restClient] uploadFile:filename toPath:destDir
withParentRev:revName fromPath:localPath];
}
Please guide why this happens and what's the reason behind this? Can this be traceable via any delegate method.
Upvotes: 1
Views: 650
Reputation: 1741
Finally i got..
- (void)restClient:(DBRestClient*)client loadMetadataFailedWithError:(NSError*)error {
NSLog(@"Error loading metadata: %@", error);
}
Got help from enter link description here
Upvotes: 1