Skip to content

Instantly share code, notes, and snippets.

@sradu
Created January 15, 2012 23:47
Show Gist options
  • Save sradu/cc5482059ae3023bdf50 to your computer and use it in GitHub Desktop.
Save sradu/cc5482059ae3023bdf50 to your computer and use it in GitHub Desktop.
NSString *path = @"/stuff.json";
NSMutableURLRequest *request = [[AFAPPAPIClient instance] multipartFormRequestWithMethod:@"POST" path:path parameters:params constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
for (int i=0; i<[self.sImages count]; i++) {
NSData *imageData = UIImageJPEGRepresentation([self.sImages objectAtIndex:i], 0.7);
[formData appendPartWithFileData:imageData name:@"pics[]" fileName:@"avatar.jpg" mimeType:@"image/jpeg"];
}
}];
AFHTTPRequestOperation *operation = [[[AFHTTPRequestOperation alloc] initWithRequest:request] autorelease];
operation.completionBlock = ^ {
if (completeSelector) {
NSLog(@"error %@", operation.error); // HERE I CAN SEE THE ERROR.
//callback
}
};
NSOperationQueue *queue = [[[NSOperationQueue alloc] init] autorelease];
[queue addOperation:operation];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment