Question

My code to get files from dropbox.This is the code from the dropbox plugin that i have made

//get the files list

- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata
{
dropBoxArray=[[NSMutableArray alloc]init];

myfolderhash=@"Backup";

for (DBMetadata* child in metadata.contents)
{


    if (child.isDirectory)
    {

        [client loadMetadata:child.path withHash:myfolderhash];
    }
    else
    {
        [dropBoxArray addObject:child.path];

        jscallback=[NSString stringWithFormat:@"getFilename(%@)",dropBoxArray];

        [self.webView stringByEvaluatingJavaScriptFromString:jscallback];

    }

    }
   NSLog(@"path%@",dropBoxArray);

   }

//method called from the javascript to display the files.

   -(void)getfiles:(CDVInvokedUrlCommand *)command
   {
     CDVPluginResult* pluginResult = nil;

     [self.restClient loadMetadata:@"/" withHash:myfolderhash];

     pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];

     self.restoreJavaScript = [pluginResult toSuccessCallbackString:command.callbackId];
     }

Warning is like:Error loading metadata: Error Domain=dropbox.com Code=400 "The operation couldn’t be completed. (dropbox.com error 400.)" UserInfo=0x17c5c4b0 {hash=Backup, path=/, error={ hash = "String contains non-hexadecimal characters"; }}

and also the I am adding the javascript to web view.Will this work???

Anybody can please help me!!! :(

Was it helpful?

Solution

This is how i changed my code.

- (void)restClient:(DBRestClient *)client loadedMetadata:(DBMetadata *)metadata
{
dropBoxArray=[[NSMutableArray alloc]init];

for (DBMetadata* child in metadata.contents)
{  


if (child.isDirectory)
{

    [client loadMetadata:child.path withHash:nil];
}
else
{
    [dropBoxArray addObject:child.path];

    jscallback=[NSString stringWithFormat:@"getFilename(%@)",dropBoxArray];

    [self.webView stringByEvaluatingJavaScriptFromString:jscallback];

}

}
NSLog(@"path%@",dropBoxArray);

}

//method called from the javascript to display the files.

 -(void)getfiles:(CDVInvokedUrlCommand *)command
 {
 CDVPluginResult* pluginResult = nil;

 [self.restClient loadMetadata:@"/" withHash:nil];

 pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];

 self.restoreJavaScript = [pluginResult toSuccessCallbackString:command.callbackId];
 }

OTHER TIPS

The error is quite right... that's an invalid hash. Why are you passing in the string "Backup" as a hash? You should only pass in a hash that came back from a previous call to metadata.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top