I'm rewriting the network code of my app to AFNetworking 2.0 using the AFHTTPSessionManager as base class. I want to reimplement my current download implementation but I'm failing to reimplement my old behaviour.
Current implementation:
Current approach:
To start the download I use the AFURLSessionManager method downloadTaskWithRequest:progress:destination:completionHandler:
. If the download is completed the destination and completionHandler block are called and everything is fine. But if I cancel the task only the completionHandler block is called and I can't find the position of the already downloaded file, which is needed to resume the download at the correct position. To resume the download I would use the downloadTaskWithResumeData:progress:destination:completionHandler:
method. But to get the already downloaded data I need the path of the tmp download file.
Question: How can I get the path of the terminated download file? Or how can I resume this download without downloading all the data again?
The NSURLSessionDownloadTask
has the cancelByProducingResumeData:
method. This will offer the resume data object which is needed to resume the download.
It's possible to save this resume data into a file and resume it later with downloadTaskWithResumeData:progress:destination:completionHandler
.