1

I am using the NSURLSession to perform the upload of a file using the chunk transfer.

self.dataTask = [self uploadTaskWithRequest:urlRequest fromData:urlRequest.HTTPBody progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
                if (error) {
                    //Error response
                } else {
                    //Success response
                }
            }];

            [self.dataTask resume];

The issue is that when the app goes to the background it will not perform the continuous upload, the ongoing upload will suspend and resumes when app goes to foreground.

I want to achieve the background transfer continuously for the chunk upload.

Any suggestion to achieve this?

Update:

Implemented the backgroundSessionConfiguration and getting the below error.

Terminating app due to uncaught exception 'NSGenericException', reason: 'Upload tasks from NSData are not supported in background sessions.

Raghav
  • 625
  • 1
  • 12
  • 31
  • you should assign background session configuration so that it should work in background. – johny kumar Feb 17 '16 at 07:12
  • Getting the error when I implemented the background session configuration. Terminating app due to uncaught exception 'NSGenericException', reason: 'Upload tasks from NSData are not supported in background sessions. – Raghav Feb 17 '16 at 09:28
  • follow this : http://stackoverflow.com/questions/25660363/upload-tasks-from-nsdata-are-not-supported-in-background-sessions – johny kumar Feb 17 '16 at 09:37
  • You need to write data to local file and grab it from there using filePath to upload on server. – The iCoder Aug 01 '19 at 09:31

0 Answers0