I used this method to POST an image to server before, but it’s a little complicated because I have to add header and boundary by myself. Yesterday I found a project called Resty – “A simple Objective-C HTTP client for iOS and Mac”. However, after reading all of its documents, I can’t find any method to upload an image file. Please help, thanks so much.
NSMutableDictionary *params = [NSMutableDictionary dictionary];
[params setObject:@"this is a title" forKey:@"title"];
// ***How can I add an image by Resty?***
[params setObject:UIImageJPEGRepresentation(self.image, 1.0) forKey:@"image"];
LRRestyClient *client = [LRResty client];
[client setUsername:userId password:userToken];
[client post:APIImageUrl payload:params withBlock:^(LRRestyResponse *response){
NSLog(@"Done");
}];
i think this framework not handle image data and custom parameters correctly you may follow this topic and create correct NSData format
How to upload image and text using HTTP POST?
or if you want more mature framework personally i advice restkit.
in my project i send image to rest service with this sample code
this slide may give idea http://www.slideshare.net/tkalapun/restfull-with-restkit