使用帶有進度跟蹤的 Dropbox Objective-C 庫下載檔案

這使用 Dropbox Objective-C SDK 從 Dropbox 下載檔案“/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);
}];