Skip to content

Instantly share code, notes, and snippets.

@jameshadley
Created February 20, 2014 21:49
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jameshadley/9123974 to your computer and use it in GitHub Desktop.
Save jameshadley/9123974 to your computer and use it in GitHub Desktop.
NSURLSessionConfiguration *configuration = [NSURLSessionConfiguration defaultSessionConfiguration];
AFHTTPSessionManager *_afHTTPSessionManager = [[AFHTTPSessionManager alloc] initWithSessionConfiguration:configuration];
// set your response content type here
NSMutableSet *contentTypes = [[NSMutableSet alloc] init];
[contentTypes addObject:@"application/json"];
_afHTTPSessionManager.responseSerializer.acceptableContentTypes = contentTypes;
[_afHTTPSessionManager.requestSerializer setAuthorizationHeaderFieldWithUsername:username password:password];
[_afHTTPSessionManager POST:postUrl parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
[formData appendPartWithFileData:videoData name:@"uploadedFile" fileName:@"video.mp4" mimeType:@"video/mp4"];
} success:^(NSURLSessionDataTask *task, id responseObject) {
NSLog(@"video operation success! %@", responseObject);
} failure:^(NSURLSessionDataTask *task, NSError *error) {
NSLog(@"Operation Error: %@", error);
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment