I am making a post from android to php with data and an image. I'm scaling the image down in android and base 64 encoding it. When it is sent via volley, most images are somewhere between 70 and 100kbs. The problem I have is that a few images for whatever reasons come out to be slightly bigger, like 130kbs. At 130kbs, the volley doesn't get a response soon enough and send the request again, creating multiple entries on my database. 30Kb's seems like a very small window, so I need to put a safety measure in place to prevent multiple entries.
I'm not sure what the best approach to solving this problem is. Is there a way to extend the initial wait period in volley? Can I handle the decoding of the image and saving on the php server asynchronously so not to slow down the response? Should I do a check to make sure the incoming request is not a duplicate?
Please let me know what you think the best solution is and why.
I don't know if Volley allows to set timeouts directly, but maybe you could use okhttp over volley. This is known to work well, and okhttp has a very clear API that will let you set both connect and read timeouts easily.
Use setRetryPolicy method which receives a DefaultRetryPolicy object, so you can pass an instance with custom values:
Hope it helps.