Good day Guys,
It's my first time to use AFKNetworking to post a file from my iOS app to our server. I'm getting a random corrupted files from some of my testers. And when I checked the error log I got an AFKNetworking -1001 error "Request timeout". I checked and modified both PHP.ini and httpd.conf to extend the timeout and maxrequestcount to allow my app to have a longer upload process but unfortunately I'm still getting this bug randomly.
Please can someone kindly help me figure this out?
Thanks in advance:)
EDIT Here's the code snippet NSMutableDictionary *params = [[NSMutableDictionary alloc] init];
[params setObject:@"*****" forKey:@"******"];
/*
code that populates params...
*/
NSMutableURLRequest *request = [[AFHTTPRequestSerializer serializer] multipartFormRequestWithMethod:@"POST" URLString:[pdl getApplicationBridgeUploadDirURL] parameters:params constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
/*
code that handles the files
*/
} error:nil];
NSURLSessionConfiguration *sessionConfiguration = [NSURLSessionConfiguration defaultSessionConfiguration];
sessionConfiguration.timeoutIntervalForRequest = 500000;
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:sessionConfiguration];
//manage queue
NSOperationQueue *operationQueue = manager.operationQueue;
NSProgress *progress = nil;
NSURLSessionUploadTask *uploadTask = [manager uploadTaskWithStreamedRequest:request progress:&progress completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
if (error) {
NSLog(@"Error*****************************");
NSLog(@"%@", error);
NSLog(@"Error*****************************");
} else {
NSLog(@"***********************************");
NSLog(@"%@ %@", response, responseObject);
NSLog(@"***********************************");
}
[progress removeObserver:self forKeyPath:@"fractionCompleted" context:NULL];
}];
[progress addObserver:self
forKeyPath:@"fractionCompleted"
options:NSKeyValueObservingOptionNew
context:NULL];
[uploadTask resume];