I am trying to do a task which I am completely not aware of, that is video uploading to server in objective c. I am a beginner and I was using swift, but now my requirement is in objective c.
Here I have to send an asynchronous request using multipart form data to server with three values. here is the data need to send in body:
body->form-data
projectId : String
sessionId : String
file : file
Its getting crashed at this line
" [urlRequest addValue:@"65" forHTTPHeaderField:@"projectId"];"
Can anyone help me to do this.
Thanks in advance.
NSString *str = [NSString stringWithFormat:@"http://abcdefghijkl.mnopqrst.com:8965/upload"];
NSURL *url = [NSURL URLWithString:str];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
[urlRequest addValue:@"65" forHTTPHeaderField:@"projectId"];
[urlRequest addValue:@"43" forHTTPHeaderField:@"sessionId"];
[urlRequest addValue:@"" forHTTPHeaderField:@"file"];
NSOperationQueue *queue = [[NSOperationQueue alloc] init];
[NSURLConnection sendAsynchronousRequest:urlRequest queue:queue completionHandler:^(NSURLResponse *response, NSData *data, NSError *error) {
if (error) {
NSLog(@"Error,%@", [error localizedDescription]);
} else {
NSLog(@"%@", [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding]);
}
}];