I am trying to upload a file and while doing so when I suspend the upload operation, the method:
- URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:
doesn't excute, which is expected. But still it continues to send the complete file to the server.
I tried uploading ~200MB file, and I suspended the operation around 10%. And when I see the server side, I could see data coming.
Below is the code:
NSFileManager *fileManager = [NSFileManager defaultManager];
NSURL *documentsURL =[[fileManager URLsForDirectory:NSDocumentDirectory inDomains:NSUserDomainMask]lastObject];
NSURL *urlPath=[documentsURL URLByAppendingPathComponent:@"video2.mp4"];
NSURLSessionConfiguration *backgroundSessionConfigObject = [NSURLSessionConfiguration backgroundSessionConfiguration:@"ud" ];
//backgorundSession is NSURLSession
self.backgroundSession =[NSURLSession sessionWithConfiguration:backgroundSessionConfigObject delegate:self delegateQueue:[NSOperationQueue mainQueue]];
NSMutableURLRequest *request=[NSMutableURLRequest requestWithURL:[NSURL URLWithString:@"http://localhost:5000/upload/"]];
request1.HTTPMethod=@"POST";
uploadTask=[backgroundSession uploadTaskWithRequest:request fromFile:urlPath];
[uploadTask resume];
I am not able to suspend the task. Though it stops the execution of below method. But it still pushes the data to the server.
- URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend: