如何将视频文件上传到网络服务器 iPhone SDK



我正在尝试使用 UIImagePickerController 将视频上传到 Web 服务器。请建议我如何做或为此提供示例。

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info

{
NSURL *urlvideo = [info objectForKey:UIImagePickerControllerMediaURL];

//urlvideo contains the URL of that video file that has to be uploaded. Then convert the url into NSString type because setFile method requires NSString as a parameter
NSString *urlString=[urlvideo path];
NSLog(@"urlString=%@",urlString);
NSString *str = [NSString stringWithFormat:@"path of server"];
NSURL *url = [NSURL URLWithString:[str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
[request setFile:urlString forKey:@"key foruploadingFile"];
[request setRequestMethod:@"POST"];
[request setDelegate:self];
[request startSynchronous];
NSLog(@"responseStatusCode %i",[request responseStatusCode]);
NSLog(@"responseStatusCode %@",[request responseString]);
}

最新更新