Skip to content Skip to sidebar Skip to footer

Android (or Ios) - Image Upload Queue

We've written an app for Android (and iOS), and it allows users to upload photos to our REST server. The issue we're hitting is that sometimes the users are in places with terrible

Solution 1:

The best option would be to save the photo to the SD card and put the path to it in a database. The database here acts like a queue. So whenever the user has access to internet, the app can check whether there are any entries in the database and start uploading. Once you upload the photo, you delete that record from the database.

Now, as far as the upload is concerned, I recommend doing it in a Service as opposed to an AsyncTask. This way you can use an AlarmManager to call the service at periodic intervals and check whether there is anything to upload.

I used this method in one of my applications but for documents. It works like a charm. Hope that helped.

Solution 2:

In iOS I used ASIHTTPRequest, but at the moment you can find other solutions (MKNetworkKit). I did an application exactly like what you are doing so what I did was:

  1. Check if there is internet, if yes continue, otherwise stop.
  2. Try to send one photo, if succeed go to the next one, otherwise leave the photo on the queue and go to the next photo.
  3. Repeat process.

Let's imagine the user putted 20 photos on the queue, and start the process, at the end of the day he could check again what succeed and what didn't. Of course he could re-send what failed in the first place.

Post a Comment for "Android (or Ios) - Image Upload Queue"