views:

158

answers:

1

Looking at using either ObjectiveResource or ASIHTTPRequest ...

  1. Which is superior for uploading images? Or is there a better option???

  2. Are there any examples of using either or both to upload images (or any other binary content)?

Thanks

A: 

I haven't used ObjectiveResource. ASIHTTPRequest is fairly easy to use. You'll probably need multipart/form-data request, so there is a ASIFormDataRequest subclass for that. I had some problems with ASIFormDataRequest and Rails though. From what I remember, images in request were accompanied by "charset=some-encoding" parameter (and it was hardcoded), so Rails wouldn't accept it as a valid image when charset=utf8 was there. Another problem was, you couldn't have arrays (like array_item[]) in your POST requests. You simply couldn't add more than one parameter with the same name. But both problems are pretty easy to patch if you really want to use ASI framework. Take a look at http://allseeing-i.com/ASIHTTPRequest/How-to-use and at the comments in ASIFormDataRequest.h

Alex Chugunov
Quick note for anyone finding this - both of the issues Alex mentioned with ASIHTTPRequest have since been resolved. Binary files no longer have an erroneous charset specified in the header - this did cause problems on some servers, as in Alex's case.Also, ASIFormDataRequest now supports uploading multiple values with the same key, so you can upload an array of images - see ASIFormDataRequest.h for details.
pokeb