我的应用需要从用户手机上传视频文件,然后在服务器上处理.问题是文件的大小可以达到200 MB以上,用户不会保持应用程序打开以等待文件上传.由于苹果不允许应用程序在后台运行超过有限的时间.如何确保上传文件.我正在使用afnetworking来设置ios 7库给出的上传任务.
如果有人能指出我正确的方向或有任何解决方案,我们将不胜感激.我已经把这个问题拖了很长时间.谢谢.
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager *manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
[manager setTaskDidSendBodyDataBlock:^(NSURLSession *session,NSURLSessionTask *task ,int64_t bytesSent, int64_t totalBytesSent,int64_t totalBytesExpectedToSend){
CGFloat progress = ((CGFloat)totalBytesSent / (CGFloat)sensize);
NSLog(@"Uploading files %lld -- > %lld",totalBytesSent,totalBytesExpectedToSend);
[self.delegate showingProgress:progress forIndex:ind];
}];
dataTask = [manager uploadTaskWithStreamedRequest:request progress:nil completionHandler:^(NSURLResponse *response, id responseObject, NSError *error) {
if (error) {
NSLog(@"Error: %@", error);
} else {
}
}];
Run Code Online (Sandbox Code Playgroud)
我的请求是正常的多部分表单请求.