Friday 26 August 2011

Uploading Video Files to Web Server

Uploading video files in iphone projects is very cumbersome.
This Blog describes how to upload video files on server using ASIFormDataRequest Method.

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

No comments:

Post a Comment