views:

45

answers:

1

Hello coders and codetts,

I created an iphone app, and i'm currently in development of a web app to go along, the main goal is to have the iphone collect data and then upload the data to the web app so that the users can view and print the data that was collected, after the data has been uploaded it will be deleted off the iphone.

Now with that data I have images stored on the iphone's file system and the path saved in coreData, i wrote the code for export which will pull all the data, out of coredata, and encode the images to base64 string and create a json file for easy transfer. so now this json file due to the encoding of images can become quite large, and sending it via email, might not be possible after about 15MB in size.

So my question is really two fold, what is the best way to transfer these images with their related data to the web app, second, if I go the base64 way, how would I convert it back to a png file to save on the web servers file system and save the path to the mysql DB. I would really like all this to happen during the upload process. I forgot to mention that I can have this JSON file transfered to the users computer, (just in case the size is to large to email) and then the user will go to the website and upload it.

The web app is being written in RUBY.

thanks for any advice. iAm --

A: 

I think, you won't need to use json, but a HTTP-Postrequest. I suggest to use ASIHttpRequest, see their chapter "Sending a form POST with ASIFormDataRequest"

Response for comment

let's say you have the files path in a NSArray called files, this should do the trick (untested)

ASIFormDataRequest *request = [ASIFormDataRequest requestWithURL:url];
for (NSString *s in files){
    [request setFile:s forKey:[NSString stringWithFormat:@"file_%@", [files indexOfObject:s]]];
}

edit

Maybe you should check "Streaming request bodies directly from disk" as-well.

vikingosegundo
Do u know if this method can handle a batch upload, possibly 20 rows of data each with an image, I was hoping to upload one file a json file and have the web app process the data. I like the method u gave just need to know if it can handle batch load, iam on my iPad and not @ a computer to test, so if u know off hand...
iAm