Last active
August 29, 2015 14:05
-
-
Save molsches/95681e86d64781136c30 to your computer and use it in GitHub Desktop.
AFNetworking on Catalyze.io
This file contains 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
//Provide variables for `myData`, `myFileName`, and `myMimeType` | |
// and #import "AFNetworking.h" | |
AFHTTPRequestOperationManager *fileHttpClient = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:@"https://apiv2.catalyze.io"]]; | |
fileHttpClient.responseSerializer = [AFHTTPResponseSerializer serializer]; | |
[fileHttpClient POST:@"/v2/users/files" parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { | |
[formData appendPartWithFileData:myData name:@"file" fileName:myFileName mimeType:myMimeType]; | |
} success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
NSDictionary *fileObject = [NSJSONSerialization JSONObjectWithData:responseObject options:0 error:nil]; | |
NSLog("file: %@", fileObject); | |
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
NSLog(@"failed to upload: %@", error); | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment