How to download a blob image from java server to iPhone app? - iphone

I have created a program which allows me to upload images to Java Server thru Multipart.
How can I receive an image from server and download it to iPhone app? Is there any way apart from NSURL i can download the image?
Base64 Encoding & Decoding seems to be not working.

If what you're downloading is base64 encoded, you can just download it using NSURLConnection. Once you have the data downloaded, base64 decode the data and put it into an NSData that can then be loaded into a UIImage. A solution for doing that can be found here on SO.
No matter what, though, you're going to need NSURL. ASIHTTPRequest provided a Core Foundation networking abstraction that is an alternative to NSURLConnection, however, it's bloated and it is no longer being maintained by the original author (though there are probably some forks that are being maintained).

Related

ASIHttpRequest replacement and image caching

I've been using ASIHttpRequest library for a while for downloading images and storing them for cache. Since it is deprecated already I'm looking for a replacement library.
My needs are to download a new image and to store it for cache only and only if image has changed on server. Otherwise to use cached image.
Is there a good and lite alternative to beloved ASIHttpRequest?
Sure there is: AFNetworking
AFNetworking is de-facto the natural replacement of ASIHTTP. It's a lovely library and version 2.0 has just being launched.
Another great library is surely SDWebImage, which provides a lot of useful functionalities for downloading and caching images.
You are clearly free to use both in your project. I personally use AFNetworking for any network operation a part from images, for which I use SDWebImage.
If you're just looking for a library to handle image downloads and caching, I recommend SDWebImage.
It includes a category class on UIImageView as well as SDWebImageManager if you're just looking to download images and not immediately place them in a UIImageView.
This link would help you it will download it and next time it will take images from cache

Uploading images from iPad in base64 format and size limit

We are developing a inspection application for iPad, where user can select multiple images from iPad and upload this images to portal, also he can enter comments on each particular image.
We are using xml for communication and converting images into base64 string format and uploading to server.
When xml size reaches around 2 MB, at the server side xml is not received and tomcat server returns Null Pointer Exception.
It will work fine if xml size is less than 2 MB.
So i would like to know is converting images to base64 is a proper way to upload images to server?
Is there any size limit for uploading data from iPad/iPhone Application?
Any help is really appreciated.
hi just compress your image
NSData *imageData = UIImageJPEGRepresentation(theImage, 0.1f);
This compress your image and then convert it to base64..
Use ASIHTTP framework for uploas an image from mobile to server
use the below link for how to upload image
http://allseeing-i.com/ASIHTTPRequest/How-to-use don't forgot to add asihttp framewok to your app
We have used PUT for HTTPMethod instead of POST and it worked properly, But I am not sure if there are any disadvantage of using PUT.

How to upload data using chunked encoding?

I want to upload audio data through chunked transfer encoding. My application reads audio buffer after each 0.5 seconds. As soon as I get data, I want to upload this data on the server using chunked encoding. Also I want to keep the connection open. So, after 0.5 seconds, when next buffer will be available, I can upload those data on same connection.
I have tried with NSMutableURLRequest and NSURLConncetion. But as soon as I start communication asynchronously, control goes to iOS and my delegates are notified. I want to upload more data using same NSURLConnection.
I have also tried with ASIHttpRequest. But I cant find a way to give data periodically and upload vi http chunking.
Please let me know if you have any standard way to upload data using transfer encoding chunked with iOS APIs.
Thanks in advance.
I would heartily recommend the AFNetworking library. It seems to be the cool kid on the block for async networking on the iPhone. It was written by the developers at Gowalla and I can vouch for it's ease of use, reliability, and speed.

iPhone: Efficiently downloading images from a URL into iPhone App

In my iPhone app , I need to display the images from server.
I need to download it and save it from URLs.
There are roughly 20 images which I need to download.
What could be a way out where in performance doesnt decrease?
I have tried previously using NSData to convert the images into NSData and saving it to my app but it takes lots of time.
What could be a more easier and efficient way out?
I recommend using ASIHTTPRequest to download the images asynchronously, and display them when they're ready. By using the asynchronous interface of that class, your app can be responsive and continue to operate normally while, in the background, you wait for the data to be loaded.
ASIHTTPRequest is open source and free to use: http://allseeing-i.com/ASIHTTPRequest/
The code the Facebook app uses to download and display images has been open-sourced as part of the three20 library.
If you want to write your own networking code ASIHTTPRequest is a very useful library that includes features such as downloading directly to a file and queue management.

How to send png images from iPhone to web service

I have been trying to send .png images from iPhone to web service. I have come so fas as converting the .png image into a byte[] array. I am clueless as to how to use soap or HTTP get/post to transfer the byte[] image to the web service.
Any help would be greatly appreciated.
Sayeed
if you want to use just an HTTP-POST, you can try the ASIHTTPRequest library. it wraps the NSHTTPRequest into an easy-to-use container.
there is also an example how to submit files (your png).