【发布时间】:2013-11-21 21:08:16
【问题描述】:
我正在处理一个需要将大文件上传到服务器的项目。我使用 NSURLSession 来设置后台传输服务。一切似乎都很好,但我相信它会继续发送 32K 的块。我想知道是否有办法增加块大小?
这是设置上传任务的示例代码:
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。
【问题讨论】:
标签: ios objective-c file-upload nsurlsession