使用AFNetwork 2.0我想支持视频的异步上传操作到我的服务器。 现在,假设由于某种原因上传失败或超时,我想尝试另一次上传尝试。有没有简单的方法来“重启”上传尝试?
假设以下代码:
NSURLSessionConfiguration* configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFURLSessionManager* manager = [[AFURLSessionManager alloc] initWithSessionConfiguration:configuration];
NSURLSessionUploadTask* uploadTask;
uploadTask = [manager uploadTaskWithRequest:req
fromData:data
progress:nil
completionHandler:^(NSURLResponse* response,
id responseObject,
NSError* error)
{
if (error)
{
HOW CAN I JUST RESTART THE UPLOAD OPERATION?
}
else
{
NSLog(@"Success: %@ %@", response, responseObject);
}
}];
[uploadTask resume];