Dropbox API Downloading a file using the Dropbox Objective-C library with progress tracking


This uses the Dropbox Objective-C SDK to download a file from Dropbox at "/test.txt".

[[[client.filesRoutes downloadData:@"/test.txt"] response:^(DBFILESFileMetadata *metadata, DBFILESDownloadError *downloadError, DBRequestError *error, NSData *fileData) {
    if (metadata) {
        NSLog(@"The download completed successfully.");
        NSLog(@"File metadata:");
        NSLog(@"%@", metadata);
        NSLog(@"File data length:");
        NSLog(@"%lu", (unsigned long)[fileData length]);
    } else if (downloadError) {
        NSLog(@"Something went wrong with the data:");
        NSLog(@"%@", downloadError);
    } else if (error) {
        NSLog(@"Something went wrong with the API call:");
        NSLog(@"%@", error);
}] progress:^(int64_t bytesWritten, int64_t totalBytesWritten, int64_t totalBytesExpectedToWrite) {
    // Here we can monitor the progress of the transfer:
    NSLog(@"bytesWritten: %lld, totalBytesWritten: %lld, totalBytesExpectedToWrite: %lld", bytesWritten, totalBytesWritten, totalBytesExpectedToWrite);