Upload videos with objective c

后端 未结 2 2030
太阳男子
太阳男子 2021-01-03 16:27

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 streami

2条回答
  •  梦谈多话
    2021-01-03 17:10

    - (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.

提交回复
热议问题