Skip to content

Instantly share code, notes, and snippets.

@ClaudeSutterlin
Created February 14, 2015 17:55
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 ClaudeSutterlin/8e9566f6a48d965b962d to your computer and use it in GitHub Desktop.
Save ClaudeSutterlin/8e9566f6a48d965b962d to your computer and use it in GitHub Desktop.
NSURL *url = <your url>;
NSURL *fileUrl = <url to file on the local system>
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];
[manager.requestSerializer setValue: self.accessToken forHTTPHeaderField:@"AccessToken"];
[manager POST: url.absoluteString parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) {
NSError *error;
[formData appendPartWithFileURL: fileUrl name:@"upload" error: &error];
NSLog(@"Error: %@", error);
} success:^(AFHTTPRequestOperation *operation, id responseObject) {
NSLog(@"Success: %@", responseObject);
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"Error: %@", error);
}];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment