سؤال

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 I'm 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.

On the server the data is going to be saved in a postgresql data base and I'd 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.

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.

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.

هل كانت مفيدة؟

المحلول

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. It adds about 37% to the size of the data
  2. If there is a problem with the connection you have to send everything again, rather than just the files that got messed up.

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.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top