使用带有进度跟踪的 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);
}];