I’ve BGProcessingTask & BGAppRefreshTask working effective. The principle objective of my use of BGProcessingTask is to add a file to AWS S3 utilizing multipart/form-data. I’ve discovered that any file above about 2.5MB instances out after operating nearly 4 minutes. If I run the identical RESTful api utilizing curl or Postman, I can add a 25MB file in 3 seconds or much less.
I’ve tried to intentionally set .earliestBeginDate to 01:00 or 02:00 native time on the iPhone, however that doesn’t appear to assist.
I exploit the delegate (sure, I’m writing in Goal C) – URLSession:job:didSendBodyData:totalBytesSent:totalBytesExpectedToSend: and discover that the iOS system uploads about 140kB each 15 seconds or so.
I’m on the lookout for suggestions or perception into how I would allow uploads of 25MB recordsdata. I’d be comfortable it I might do only one a day for my use case.
I present code on how I arrange the NSURLSession and NSURLSessionDownloadTask, as it’s my guess that if there’s something that must be modified it’s there.
I’ve to imagine there’s a resolution for this since I learn in lots of posts right here and in Apple Developer how builders are utilizing this performance for importing many, many recordsdata.
NSURLSessionConfiguration *sConf = [NSURLSessionConfiguration backgroundSessionConfigurationWithIdentifier:bkto.taskIdentifier];
sConf.URLCache = [NSURLCache sharedURLCache];
sConf.waitsForConnectivity = YES;
sConf.allowsCellularAccess = NO;
sConf.networkServiceType = NSURLNetworkServiceTypeVideot;
sConf.multipathServiceType = NSURLSessionMultipathServiceTypeNone;
sConf.discretionary = YES;
sConf.timeoutIntervalForResource = kONEHOURINTERVAL;
sConf.timeoutIntervalForRequest = kONEMINUTEINTERVAL;
sConf.allowsExpensiveNetworkAccess = NO ;
sConf.allowsConstrainedNetworkAccess = NO;
sConf.sessionSendsLaunchEvents = YES;
myURLSession = [NSURLSession sessionWithConfiguration:sConf delegate:self delegateQueue:nil];
and later
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:pth]];
request.HTTPMethod = kHTTPPOST;
request.HTTPBody = [NSData my body data];
request.timeoutInterval = 60;
[request setValue:@"*/*" forHTTPHeaderField:@"Accept"];
[request setValue:@"en-us,en" forHTTPHeaderField:@"Accept-Language"];
[request setValue:@"gzip, deflate, br" forHTTPHeaderField:@"Accept-Encoding"];
[request setValue:@"ISO-8859-1,utf-8" forHTTPHeaderField:@"Accept-Charset"];
[request setValue:@"600" forHTTPHeaderField:@"Keep-Alive"];
[request setValue:@"keep-alive" forHTTPHeaderField:@"Connection"];
NSString *contType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",bnd];
[request setValue:contType forHTTPHeaderField:@"Content-Type"];
[request addValue:[NSString stringWithFormat:@"%lu",(unsigned long)myData.length] forHTTPHeaderField:@"Content material-Size"];
NSURLSessionDownloadTask *downloadTask = [myURLSession downloadTaskWithRequest:request];
downloadTask.countOfBytesClientExpectsToSend = bd.size + 500;
downloadTask.countOfBytesClientExpectsToReceive = 5000;
NSLog(@"%s: downloadTask = %@, time %@",__FUNCTION__,downloadTask,[NSDate date]);
[downloadTask resume];
and listed here are logs exhibiting the rare uploads of small information chunks:
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: job = BackgroundDownloadTask <76A81A80-4703-4686-8742-A0048EB65108>.<2>, time Fri Mar 7 16:25:21 2025
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: bytesSent = 393,216
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: totalBytesSent = 393,216
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: job = BackgroundDownloadTask <76A81A80-4703-4686-8742-A0048EB65108>.<2>, time Fri Mar 7 16:25:27 2025
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: bytesSent = 131,072
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: totalBytesSent = 524,288
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: job = BackgroundDownloadTask <76A81A80-4703-4686-8742-A0048EB65108>.<2>, time Fri Mar 7 16:25:42 2025
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: bytesSent = 131,072
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: totalBytesSent = 655,360
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: job = BackgroundDownloadTask <76A81A80-4703-4686-8742-A0048EB65108>.<2>, time Fri Mar 7 16:25:56 2025
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: bytesSent = 131,072
-[BKSessionManager URLSession:task:didSendBodyData:totalBytesSent:totalBytesExpectedToSend:]: totalBytesSent = 786,432