-3

Here's what I'm looking to accomplish:

Send a photo from an ios app to a server app for processing with imagemagick.

Is pushing a photo out of ios is fairly trivial? I'm looking for suggestions on what language to create the server app with? should it be a rest service? php? ruby? node?

Thanks for any suggestions

Sam Luther
  • 1,170
  • 3
  • 18
  • 38

1 Answers1

0

Pushing out of iOS is insanely trivial. All you're doing is getting access to the image and submitting it as NSData in the HTTP body. I'd recommend using AFNetworking if you're new as it's pretty quick to pick up for your networking needs.

Your main commands for submitting out of iOS using AFNetworking are

NSData *imageToUpload = UIImageJPEGRepresentation(imageToUpload, 1.0);

and

NSMutableURLRequest *request = [[AFNetworkingClient] multipartFormRequestWithMethod:@"POST" path:@"YourURLPath" parameters:AnyParametersYouHaveInADictionaryFormat constructingBodyWithBlock: ^(id <AFMultipartFormData>formData) {
    [formData appendPartWithFileData: imageToUpload name:@"image" fileName:@"temp.jpeg" mimeType:@"image/jpeg"];
}];

That's pretty much it. For a full answer that I took these snippets from, click here.

If you would rather not use AFNetworking, then here or here may also be good places to look. Please try to do some of your own research before asking 'is it trivial' next time. StackOverflow is meant for asking specific technical questions, not general open-answered questions (i.e. is it trivial or what language should I implement the server-side in).

As for your server, that really depends on your skills, interests, and what you have access to. It's like asking us how you want to cook your dinner. Any language that can accept HTTP request with an image and run imagemagick will work. I have a preference towards rails just because I like the language more and I think that more people are learning it than PHP (which means more candidates to fix/maintain/enhance it in the future).

Community
  • 1
  • 1
LyricalPanda
  • 1,424
  • 14
  • 25
  • thanks very much for your reply. Much appreciated, sorry about the trivial thing, I actually edited that from "I assume it's.." Regardless, I hear you. Why would one not want to use AFNetworking? some type of overhead or bloat? – Sam Luther Jul 31 '14 at 15:13
  • `AFNetworking` is actually a really powerful networking tool that has a lot built in and simplifies networking down really well. However, it does mean that for the common man, there are some features you may not use. And `NSURLSession` now makes it really easy to implement a DIY version of `AFNetworking` pretty quickly. So some people prefer to do it themselves so they know exactly what is going into their networking code. Having said that, `AFNetworking` is pretty widely known and used. – LyricalPanda Jul 31 '14 at 15:22