title: Android- How to handle incomplete image uploads
body: <p>In the app Im working on at the moment we are allowing the user to upload images to our server. Im doing this in an asyncTask thread and using httpMime and sending the image as a byte array in one of the multipart entity fields. Id say about 80 % of the time this works great. The images show up on the server in a mySql table as longBlob's no problem. The other 20 percent the image gets lost on upload due to various changes in network conditions or on older less capable devices that Ive tested on (HTC dream/tmobile G1) the memory would poop out. The memory issues Ive dealt with by adding a series of catch blocks so that is no longer an issue.  Ive tried playing with httpconnectionparams but Im not to sure if that had much effect on the problem.</p>
  
  <p>How ever.....now I need a little guidance as to how to handle images lost due to network issues such as latency, switches from 4g to edge, and other problems such as total loss of coverage. I was thinking about a background service which would check any returning ojects from the server and if the object had no image associated with it, queue the background service to retry an upload.  My main concern isnt that a image isnt making it to my server during testing but occasionally when testing while driving or somewhere on the edge of tower service the app will transmit only a partial image which I can see in my database. </p>
  
  <p>So.....my question to the community this time is how have you handled such a problem. One way I was thinking of trying is sending the actual size of the file along in the multipart transmission to the server and if when the image hits the php I have set up and doesnt match the size of the int representing the file size then send back a flag value in the response. Then based on the response the app gets back it could possibly fire off the asynctask again to reupload the photo. That approach would be pretty simple to set up but I would like something a bit more fail proof and besides if the user goes into no coverage for along time I would have this zombie process chewing up their battery.....no good.  </p>
  
  <p>Like always any help on the matter with opinions, links, or other help would be much appreciated :)</p>