ResumeData gets null when using downloadTaskWithRequest

If I use this code below

aDownloadTask = [self.backgroundSession downloadTaskWithURL:aRemoteURL];

Desc of above code: When I started the download using downloadTaskWithURL , it returns expectedContentLength negative (-1) . But this time resumes receiving data.

Other To solve the above problem I use this code below

NSMutableURLRequest *aURLRequest = nil;
aURLRequest = [[NSMutableURLRequest alloc] initWithURL:aRemoteURL cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:60.0];
[aURLRequest setHTTPMethod:@"POST"];
[aURLRequest setValue:@"identity" forHTTPHeaderField:@"Accept-Encoding"];

aDownloadTask=[self.backgroundSession downloadTaskWithRequest:aURLRequest];

Desc of above code:Using the above code, expectedContentLength is excellent. But the problem is that when paused, it loads renewable data every time.

That's why my download starts from the beginning, and not from the moment I pause.

Thanks in advance

+4
1

, . .

[aURLRequest setHTTPMethod:@"POST"];
+3

Source: https://habr.com/ru/post/1648606/


All Articles