3
我正在處理一個需要上傳大文件到服務器的項目。我使用NSURLSession來設置後臺傳輸服務。一切似乎工作得很好,但我相信它繼續發送在32K的塊。我想知道是否有辦法增加塊大小?iOS:如何增加NSURLSession上傳任務的塊大小?
下面是建立一個上傳任務的示例代碼:
NSURLSessionConfiguration *sessionConfig = [NSURLSessionConfiguration backgroundSessionConfiguration:identifier];
sessionConfig.HTTPMaximumConnectionsPerHost = 1;
NSURLSession *upLoadSession = [NSURLSession sessionWithConfiguration:sessionConfig delegate:self delegateQueue:nil];
NSMutableURLRequest *request = [self configureURLRequest];
NSURLSessionUploadTask *uploadTask = [upLoadSession uploadTaskWithRequest:request fromFile:[NSURL fileURLWithPath:filePath]];
[uploadTask resume];
這裏的委託示例代碼:
- (void)URLSession:(NSURLSession *)session task:(NSURLSessionTask *)task didSendBodyData:(int64_t)bytesSent totalBytesSent:(int64_t)totalBytesSent totalBytesExpectedToSend:(int64_t)totalBytesExpectedToSend {
DLog(@"didSendBodyData: %lld, totalBytesSent: %lld, totalBytesExpectedToSend: %lld", bytesSent, totalBytesSent, totalBytesExpectedToSend);
}
再次,是有增加的塊大小使用NSURLSession上傳方式?默認情況下它是32K。