0

I'm having trouble with file download. My app is using AFURLSessionManager and make NSURLDownloadSessionTask by (NSURLSessionDownloadTask *)downloadTaskWithRequest:progress:destination:completionHandler:.

NSURLSessionDownloadTask *task = [[DownloadTask sharedInstance] downloadTaskWithRequest:request 
                                      progress:nil 
                                      destination:nil 
                                      completionHandler: ^(NSURLResponse * _Nonnull response, 
                                                       NSURL * _Nullable filePath, 
                                                       NSError * _Nullable error) {
    self.resumeData = error.userInfo[NSURLSessionDownloadTaskResumeData];
}];

It works nice usually but sometimes its download starts from the beginning when I change network. LTE->Wifi, Wifi->another Wifi, Wifi->LTE.

I tried to use resumeData but there's no error, so resumeData is nil, just start file download from the start again.

Can anyone give me a hint solve this situation?

Thank you for your help.

Justin.Shim
  • 317
  • 2
  • 14
  • What is AFURLSessionManager? – El Tomato May 12 '21 at 07:12
  • @ElTomato It's part of AFNetworking. – Justin.Shim May 12 '21 at 07:14
  • Is the problem server-specific? Content-type specific? Have you tried reusing the previous resumeData blob? Wait, what do you mean there's no error? If there's no error, you should have a filePath and a response object. Are you sure the content didn't cease to exist between retries? ETag problem? See https://stackoverflow.com/questions/36257103/nsurlsession-cant-get-resume-data-after-calling-cancelbyproducingresumedata for other ideas. – dgatwood May 19 '21 at 00:30
  • @dgatwood Thank you for your reply. I thought it was iOS-side issue, but it was server-side issue. Server conforms the five limitation that Apple says server must follow. But something is wrong. We are investigating which one is wrong. Maybe 'Range' header issue. – Justin.Shim May 20 '21 at 01:16

0 Answers0