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:
- Download a file to the tmp folder
- If download successful move file to destination path
- If download failed/cancelled leave downloaded data in the tmp folder
- If user wants to resume the download (starts download again) check the tmp folder and resume the download at the position where the last download was terminated
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?