在一个传输发送数据/文件服务器中的Andr​​oid最好的方法 [英] best way to send data/files in one transmission to server in android

查看:208
本文介绍了在一个传输发送数据/文件服务器中的Andr​​oid最好的方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我在作品中的应用程序使用GPS数据文件标记到一个位置,用户可以再回去看看在该位置以后。但是我坚持就如何我的数据发送到我希望用户以后能够看到该服务器。

The application that I have in the works uses gps data to mark files to a location which the user can then go back and see at the location later on. However I am stuck on how to send my data to the server which I want users to be able to see later.

我很好奇什么从社区要知道这里是这是去的最佳途径。我已经从位置管理器的全球定位系统数据和它的相关的类但林不知道如何发送与图像,声音文件,或视频一起在一个无缝数据传送到可以被存储在后来检索到的服务器通过根据用户的权限的设备

What I was curious to know from the community here is which is the best way to go about that. I already have the gps data from the location manager and its associated classes but Im not to sure how to send that along with an image, sound file, or video in one seamless data transmission to the server where it can be stored in then later retrieved by the device according to the users privileges.

在服务器中的数据将被保存在一个PostgreSQL数据库和Id想拥有它,每个上传绑成某种形式的是,我有应用拉动相关联的JSON阵列数据的JSON数组相关联的所有数据立场和他们的标记

On the server the data is going to be saved in a postgresql data base and Id like to have it all data associated with each upload tied into a json array of some kind being that I have the app pulling data in json arrays associated with positions and their marks

所以我应该送出去的GPS数据为文字字符串,该服务器上的一个脚本可以解析为JSON格式,如果是这样,才有可能做到这一点与图像连接到它,以及........我知道它可能的,但我想我只是还没有想通出来呢:p

so should I send out the gps data as literal strings that a script on the server can parse into json format and if so is it possible to do that with an image attached to it as well........I know its possible but I guess I just havent figured it out yet :p

或者我应该使用某种库或东西的图像/文件绑定到GPS数据和存储在一个JSON阵列中的数据发送出去。

Or should I use some kind of library or something to bind the image/files to the gps data and send them as data stored in a json array.

在朝着正确的方向屁股踢会更AP preciated :)

a kick in the butt in the right direction would be much appreciated :)

推荐答案

我总是发现发送文本数据(如GPS值)最简单的,如果做的JSON。如果你必须把图像/声音文件到这个问题,以及你可以通过编码数据,并把得到的字符串中的JSON的base64做到这一点。
我个人不喜欢的base64有两个原因:

I always find sending textual data (like gps values) easiest if done as JSON. If you have to put image/sound files into this as well you can do this by base64 encoding the data and putting the resulting string in the JSON. Personally I don't like the base64 for 2 reasons:


  1. 它增加了约37%的数据
  2. 的大小
  3. 如果有一个与你再次发送的一切,而不是只是弄乱文件的连接有问题。

另一种方法是链接的图像/带UDID声音。你引用的先发JSON,然后分别发送每个文件的处理程序接受的UDID作为参数,所以它知道正在接收的文件在服务器上。当出现连接问题你只需要重新发送一个文件的方式。

Another way is to link images/sounds with a UDID. You send the JSON first with the references and then send each file separately to a handler on the server that accepts the UDID as the argument so it knows which file is being received. That way when there is a connection problem you only need to resend a single file.

这篇关于在一个传输发送数据/文件服务器中的Andr​​oid最好的方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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