Created
April 2, 2015 12:29
-
-
Save zekunyan/62ec67e65965057e876f 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
UIImage *image = [UIImage imageNamed:@"a"]; | |
NSData *imgData = UIImageJPEGRepresentation(image, 1.0); | |
NSString *url = @"http://120.24.247.190/RCPR/detect_landmark"; | |
AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager]; | |
//Very important!!! | |
manager.responseSerializer.acceptableContentTypes = [[NSSet alloc] initWithObjects:@"text/html", nil]; | |
[manager POST:url parameters:nil constructingBodyWithBlock:^(id<AFMultipartFormData> formData) { | |
//Construct image data | |
[formData appendPartWithFileData:imgData name:@"img" fileName:@"avatar_real_small.jpg" mimeType:@"image/jpg"]; | |
} success:^(AFHTTPRequestOperation *operation, id responseObject) { | |
//Success | |
//responseObject is Json Dictionary | |
} failure:^(AFHTTPRequestOperation *operation, NSError *error) { | |
//Fail... | |
}]; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment