AFNetworking + big download files + resume downloads

被刻印的时光 ゝ 提交于 2019-12-02 21:19:52

Update:

As steipete may wont maintain AFDownloadRequestOperation any more (https://github.com/steipete/AFDownloadRequestOperation/pull/68). NSURLSessionDownloadTask may be a better choice.


https://github.com/steipete/AFDownloadRequestOperation

Also, I write a lib base on AFDownloadRequestOperation: https://github.com/BB9z/RFDownloadManager

I ended up using the old (non ARC) ASIHTTPRequest framework for a similar task. AllowResumeForFileDownloads does what you need. Note that you server needs to support resuming by reading the Range http header.

if (![[NSFileManager defaultManager] fileExistsAtPath:downloadPath]){
    ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
    [request setDelegate:self];
    [request setAllowResumeForFileDownloads:YES];
    [request setDownloadDestinationPath:downloadPath];
    [request setTemporaryFileDownloadPath:tmpPath];
    [request startAsynchronous];
}
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!