机器人(或IOS) - 图像上传队列 [英] Android (or iOS) - Image Upload Queue

查看:288
本文介绍了机器人(或IOS) - 图像上传队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我们已经写了为Android(和iOS)的应用程序,它允许用户将照片上传到我们的REST服务器。我们打​​的问题是,有时用户在可怕的细胞信号没有WIFI的地方。所以,我在想,如果有任何一个prebuilt解决方案,或推荐的途径拿地是否有可用的只有乏善可陈网络选项推迟这些上传到以后。

We've written an app for Android (and iOS), and it allows users to upload photos to our REST server. The issue we're hitting is that sometimes the users are in places with terrible cell signal and no WIFI. So, I was wondering if there was either a prebuilt solution, or a recommended path to take to defer these uploads until later if there are only lackluster network options available.

现在在Android上我使用的AsyncTask上传拍摄图像的流再presentation。图像的最大尺寸被裁剪到1280,而另一个方面缩放,所以影像没有大规模

Right now on Android I'm using an AsyncTask to upload a stream representation of a captured image. The image's maximum dimension is cropped to 1280, and the other is aspect scaled, so the images aren't massive.

,用户可以具有长达2个小时我想象没有信号,所以它会不需要尝试上载每分钟。此外,可能有多个上传,所以一些队列是必要的,我想。

The user may have no signal for up to 2 hours I imagine, so it'd not need to attempt to upload every minute. Additionally, there may be multiple uploads, so some kind of queue is needed, I think.

我还不能肯定是什么iOS应用被利用,但我可以找出是否有帮助。

I'm not positive what the iOS app is leveraging, but I can find out if it helps.

推荐答案

最好的办法是将照片保存到SD卡上,并把它的路径在数据库中。该数据库在这里就像一个队列。所以,只要用户接入互联网,应用程序可以检查是否有数据库中的任何条目,并开始上传。一旦你上传的​​照片,你从数据库中删除该记录。

The best option would be to save the photo to the SD card and put the path to it in a database. The database here acts like a queue. So whenever the user has access to internet, the app can check whether there are any entries in the database and start uploading. Once you upload the photo, you delete that record from the database.

现在,只要上传而言,我建议做一个服务,而不是一个AsyncTask的。这样,您就可以使用AlarmManager调用每隔一段时间服务,并检查是否有任何上传。

Now, as far as the upload is concerned, I recommend doing it in a Service as opposed to an AsyncTask. This way you can use an AlarmManager to call the service at periodic intervals and check whether there is anything to upload.

我在我的应用程序之一,但对于文件中使用此方法。它的工作原理就像一个魅力。希望帮助。

I used this method in one of my applications but for documents. It works like a charm. Hope that helped.

这篇关于机器人(或IOS) - 图像上传队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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