Created: 2011-07-16 19:40
Updated: 2017-08-18 03:55


Cocoa Simple Multipart Post

This library provides a really simple implementation for Multipart Data for Cocoa NSMutableURLRequest.


Just clone the repository and copy the files on your project.


Here is a simple example on how to use this library:

#import "NSMutableURLRequest+MultipartBody.h"

NSData *fileData = [NSData dataWithContentsOfFile:@"myfile.jpg" options:NSDataReadingMapped | NSDataReadingUncached error:nil];
NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:@""]];
[request addMultipartDataToBody:fileData fieldName:@"file" fileName:@"myfile.jpg" contentType:@"image/jpeg"]

NSData *responseData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];


This code was made with garbage collector on, it needs changes in order to use without GC (in iPhone for example), but I mean the changes will be simple to made.

Cookies help us deliver our services. By using our services, you agree to our use of cookies Learn more