使用目标c上传视频 [英] Upload videos with objective c

查看:114
本文介绍了使用目标c上传视频的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我现在要构建一个非常复杂的(至少对我来说)应用程序。基本应用程序如下:

I am to build a really complicated (at least to me) app now. The basic app is as follows:

标签栏应用程序,带有两个选项卡,一个用于本地视频,另一个用于流式传输视频。

A tab bar app with two tabs, one for local videos and the other for streaming videos.

现阶段很简单,但现在我必须上传视频(从iphone库中拍摄或用户拍摄)到服务器。

It is simple at this stage but now i have to upload videos (either taken from iphone gallery or shoot by users) to the server.

真的不知道怎么做。请帮助我。

Don't really have any idea how to do it. Please help me.

推荐答案

- (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]);
    }

希望这段代码可以节省您的几个小时。

Hope this code will save your couple of hours.

这篇关于使用目标c上传视频的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆