Sending image via android volley with php [closed]
Asked Answered
C

2

3

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.

Cuevas answered 15/11, 2013 at 22:32 Comment(0)
N
2

Use setRetryPolicy method which receives a DefaultRetryPolicy object, so you can pass an instance with custom values:

myVolleyRequest.setRetryPolicy(new DefaultRetryPolicy(initialTimeoutMs, maxNumRetries, backOffMultiplier));

Hope it helps.

Neral answered 16/11, 2013 at 1:56 Comment(0)
B
0

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.

Bringingup answered 16/11, 2013 at 8:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.