开发者

Transfer images from iphone app to online web app

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 woul开发者_JAVA百科d 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 --


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜