1

Here is the scenario, simply I'm opening a photo from gallery or capturing a photo from camera Intent, then using converting the returned image to base64 & using standard code of HttpClient/HttpPost, trying to upload it to a RESTful web service. problem appears when during photo upload from my android application, device's Internet connection is lost and parts of the photo's Base64 is uploaded. so image appears like this on the server:

enter image description here

any idea guys?

kevoroid
  • 5,052
  • 5
  • 34
  • 43

2 Answers2

0

Try to check the length of the image in the server and compare it to the length of the image in your device

Saif Hamed
  • 1,084
  • 1
  • 12
  • 17
0

You could provide on your PostRequest an value called for example "pictureSize". So the server can verify the size and if it's ok, he answered with a statuscode (200). Maybe we can call it handshake, if the app dont get a code the upload is not finished and so on.

loose11
  • 607
  • 6
  • 31
  • needed a better solution but had this idea as well. i used a md5sum checksum to check and compare after end of upload on server-side. – kevoroid Sep 26 '13 at 13:01
  • thats is also an option. but what about 1bit is wrong, then you have to upload the whole picture. if you use the size, there could be an little bit error and it doesn't have an impact to the upload & picture. – loose11 Sep 26 '13 at 13:46