[self.sharedDownloadManager cancelAllDownloadsAndRemoveFiles:YES];
请将YES换为NO,YES是在取消的同时删除未下载完的文件,如果你想测试续传功能,未下载完的文件肯定不能删除
const double kBufferSize = 1024*1024; // 1 MB 当接收的数据大于1M的时候才进行写文件操作,所以建议还是找个大于4M的文件进行测试吧
找到TCBlobDownload.m这个文件,找到
- (void)start 这个方法,接着找到
uint64_t fileSize = [[fm attributesOfItemAtPath:self.pathToFile error:nil] fileSize];
NSString *range = [NSString stringWithFormat:@"bytes=%lld-", fileSize];
[fileRequest setValue:range forHTTPHeaderField:@"Range"];
这几行代码,
请加上_receivedDataLength += fileSize;
加上之后大概是这样的
else {
uint64_t fileSize = [[fm attributesOfItemAtPath:self.pathToFile error:nil] fileSize];
_receivedDataLength += fileSize;
NSString *range = [NSString stringWithFormat:@"bytes=%lld-", fileSize];
[fileRequest setValue:range forHTTPHeaderField:@"Range"];
}
- (void)connection:(NSURLConnection*)connection didReceiveResponse:(NSURLResponse *)response
同理
_expectedDataLength = [response expectedContentLength];
_expectedDataLength += _receivedDataLength;
关于TCBlobDownload