简体   繁体   中英

DropboxSDK: error making request to /1/metadata/sandbox - (401) No auth method found. Can we trace this error using any dropbox delegate?

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.

Finally i got..

- (void)restClient:(DBRestClient*)client loadMetadataFailedWithError:(NSError*)error {

NSLog(@"Error loading metadata: %@", error);

}

Got help from enter link description here

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM