Created
May 14, 2014 20:34
-
-
Save mattt/2fa6d0f5e544b54952d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
[manager.requestSerializer setAuthorizationHeaderFieldWithUsername:@"user" password:@"Pa55w0rd"] | |
NSURL *filePath = [NSURL fileURLWithPath:@"file://path/to/image.png"]; | |
[manager POST:@"http://example.com/resources.json" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { | |
[formData appendPartWithFileURL:filePath name:@"image" error:nil]; | |
} 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