I'm writing an app for a customer's web-service. The service is a cloud storage. So, one of my tasks is to upload all photo gallery to this cloud. While solving this problem, i faced the following issue. I'm using a NSURLSession for that, and some photo data receives NSURLAuthenticationChallenge. In my NSURLSessionDataDelegate, i've tried to do the following -
- (void)URLSession:(NSURLSession *)session
task:(NSURLSessionTask *)task
didReceiveChallenge:(NSURLAuthenticationChallenge *)challenge
completionHandler:(void (^)(NSURLSessionAuthChallengeDisposition disposition, NSURLCredential *credential))completionHandler
{
NSLog(@"challenge recieved!") ;
self.authentcationChallengeLock = true ;
completionHandler(NSURLSessionAuthChallengeUseCredential, [NSURLCredential credentialForTrust:challenge.protectionSpace.serverTrust]);
}
But this helps for some photos, but doesn't help for another - NSURLSession simply stops executing. In my previous experience, i was uploading photos to different social networks servers or others customers servers and didn't faced this trouble. Algorithm of uploading has always been the same -
- Using OAuth token, receive file server access token and address
- Perform PUT or POST request
Moreover, photos passed NSURLAuthenticationChallenge, are uploading twice. What shall i say to server backend engineers to fix this strange behavior? Thanks in advance.