Search code examples
iphonedropboxdropbox-apinsdocumentdirectory

Dropbox API on iPhone: How to download and access the data


I am downloading files from Dropbox into the user's Documents folder using this:

[[self restClient] loadFile:filepath intoPath:[self getDocumentPath]];

    -(NSString *)getDocumentPath {
        NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
        NSString *filepath = [[NSUserDefaults standardUserDefaults] stringForKey:@"filepathDropbox"];
        NSString *path = [[paths objectAtIndex:0] stringByAppendingPathComponent:filepath];
        [[NSUserDefaults standardUserDefaults] setObject:path forKey:@"filepathDropbox"];
        return path;
    }

Once this is completed, how do I access this file on the local iphone?


Solution

  • Have you tried something like

    NSData *data = [NSData dataWithContentsOfFile:[self getDocumentPath]];
    

    ?