I use NSURLSessionDownloadTask to download a file from server, it is run in a background session. I want to save resume data to resume the download when the app is terminated. However, the call of cancelByProducingResumeData always returns null. I cannot figure out the issue, cause I used to do a sample of resumable download task successful before. Does anybody get the same issue?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Do you know if the request satisfies the criteria outlined in the documentation for the cancelByProducingResumeData
method?
A download can be resumed only if the following conditions are met:
- The resource has not changed since you first requested it
- The task is an HTTP or HTTPS GET request
- The server provides either the ETag or Last-Modified header (or both) in its response
- The server supports byte-range requests
- The temporary file hasn’t been deleted by the system in response to disk space pressure