I’m trying to upload an image to a server, and having difficulty wrapping my head around the concept of a multipart request, if it is possible to have some sort of explanation, that would be great.
The other issue I’m having is creating one in objective-c. I’m trying to upload a UIImage, and I’ve got the data all encoded to base 64 like I’ve seen in other parts, but how do I generate the request itself?
Also, I would like to avoid using 3rd party libraries, so I can understand what is going on more, instead of “oh, it’s magic that this library does for me”.
You’ll need to use
setHTTPBody:on anNSMutableURLRequestfor the content you want to upload. Obviously that content will need to comply with RFC 2388.All of this can be done by hand, but third party libraries make it easier, and will handle more edge-case scenarios than your own code, unless you want to put a lot of effort into re-inventing the wheel.