通过Android的凌空用PHP发送图像 [英] Sending image via android volley with php

查看:168
本文介绍了通过Android的凌空用PHP发送图像的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在从机器人后到PHP的数据和图像。我缩放图像倒在Android和基地64编码它。当它通过发送抽射,大部分图像是某处70和100kbs的。我的问题是,一些图片因为种种原因,出来要稍微大一些,像130kbs。在130kbs,凌空没有得到回应很快就好了,然后重新发送该请求,在我的数据库中创建多个条目。 30KB的似乎是一个非常小的窗口,所以我需要把安全措施到位,以prevent多个条目。

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.

我不知道该怎么解决这个问题最好的办法是。有没有一种方法来延长凌空最初的观望期?我可以处理图像的解码,节省了PHP的服务器上的异步所以不会减慢反应?我应该做一个检查,以确保传入的请求不是重复?

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.

推荐答案

使用 setRetryPolicy 接收一个DefaultRetryPolicy对象,这样你就可以通过一个实例使用自定义值的方法:

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.

这篇关于通过Android的凌空用PHP发送图像的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆