Currently I am sending images between an IOS app and Java web service as Strings - is there a better way to do this and if so what method is it - the Strings to represent images are huge and its quite hard to manage.
Thanks
Currently I am sending images between an IOS app and Java web service as Strings - is there a better way to do this and if so what method is it - the Strings to represent images are huge and its quite hard to manage.
Thanks
If the image implementation you're using is serializable, serialize it.
I understood that you are currently using BASE64 encoded images being represented as strings, correct?
This approach is reasonable for small binaries/images and also to avoid many individual calls for each image in case of an list of images for example.
Anyway - a proper way would be to use a POST or PUT request to send an image to a Java web service in form of an x-www-form-urlencoded request. This is similar to what you do in a typical upload form.
Look at the example in this answer: Send image to server as binary data
For the download of an image you can use a GET NSURLRequest (include required headers, authentication or other information to the request) and convert the received NSData to an image.
[UIImage imageWithData:dataReceivedFromURLRequest];
Or directly create the NSData for simple http requests like this and convert it to an image:
NSData *urlData = [NSData dataWithContentsOfURL:[NSURL URLWithString:@"http://my-web-service/image.png"]];
On the server side you could create an image REST endpoint using JAX-RS for example.
Please note that frameworks like AFNetworking help a lot providing convenient ways sending and receiving image/binary data.