iOS Client + Rest API to upload photos - ios

I have a basic requirement of uploading an image from an iOS App to a remote server. I know that I can use NSURLConnection to transfer the image to a remote server but I need to develop a REST Webservice also in the remote server which can accept images from the iOS Client and store inside a DB/hard disk .
Can anyone please suggest me the best method/libraries which can be used to to develop the REST Webservice .

I'd recommend using Ruby on Rails with the Paperclip gem.
If it's completely new to you, you can start with the Guides.
There's a lot of material on how to build a RESTful API with Rails, like this screencast.
Once you've understood how to develop an API, and how to use Paperclip to save images on the server, the answer to this question might help you with the file upload part.

Related

ReactJS and AWS-S3 Upload from the client side

I have a single page application built with ReactJS and MobX for the front end part, and ruby on rails for the backend part. I have an image drop zone container, and I want the user to be able to upload images, but all the uploading implementation to be done in the front-end part, and the backend only will receive the URL from the uploaded image. Is it possible to accomplish this with ReactJS without involving the server at all?
Yes there is a concept called as direct upload which you can use to do this. Here is an article by heroku to do this https://devcenter.heroku.com/articles/direct-to-s3-image-uploads-in-rails
You can also look into the gem carrierwave direct https://github.com/dwilkie/carrierwave_direct
You might also want to check out http://docs.aws.amazon.com/sdkforruby/api/Aws/S3/Presigner.html
and
https://www.npmjs.com/package/react-s3-uploader
If you are willing to use a easy to use managed service filestack.com is a good option.

How to connect from your iOS app to a backend server? how to read, modify and fetch data to backend server?

I am new in developing iOS applications. I like to learn communication between my app and a specific back-end server(which is written in ruby). I would like to learn how to read, fetch and modify data on the back-end server? I do not have any idea where I should start? I am very welcome if you could refer me to any online resource/tutorial for this topic.
First, you have to create an API in ruby. Here is a tutorial on how to do it: https://www.codeschool.com/courses/surviving-apis-with-rails.
After that, when you are sure that your API is working correctly, you can write a service for HTTP communication. You can do it by yourself, but in my opinion, a much better option would be using the third party for that. I prefer using AFNetworking: https://github.com/AFNetworking/AFNetworking.
You can also use Heroku. First you can create your API and make some tests then implement to your server.

Mobile upload file to S3 using a Rails Rest API

I have a web app in Rails that has a profile image upload, I`m using Refile gem to upload the photo direct to Amazon S3.
But now I need to do this upload from a mobile app too.
Witch is the best way to do that?
I think about a Rest API in Rails that receives the binary data and then uses Async Jobs (Sidekiq) to upload to Amazon S3, but and not sure if the approach is best way.
Can anyone help me?
Thanks!

How to upload an image to another server via HTTP post using carrierwave(Ruby On Rails)?

I am trying to upload an image to another server via HTTP post using carrierwave? What I understand so far is, Carrierwave supports some known cloud storage. but, in our application, we have a separate storage system with MongoDB. In order to store any file in that server, we can use HTTP post. Now, I am trying to write a client code to upload image. Is it possible to achieve by using Carrierwave or is there any other gem available?
Thanks in advance.
If you're using CarrierWave and MongoDB, I would use the https://github.com/jnicklas/carrierwave-mongoid gem to connect and store directory in GridFS.
Here's a good post on uploading and retrieving an image via carrier wave and gridfs: http://hafizbadrie.wordpress.com/2011/04/14/image-upload-with-carrierwave-and-mongoid-gridfs-mongodb-in-rails-3/
you need to provide your data where there is s3 data in the tutorials:
stack overflow

Setting up a file server for integration with iOS apps

I need to set up a server so that files can be uploaded from an iOS app. I don't know how best to proceed. I thought about FTP but not sure if there is a better option.
any ideas appreciated
GC
Also I must add that I will be building the iOS app so can use server APIs in my code.
It's not ideal to set up a blind File/FTP server and hardcode the details into your app because all it takes is one person to intercept the login details and they have access to your server where they can upload (and potentially execute) bad things.
A possible idea could be to set up an API frontend on your server in a language of your choice (PHP, Ruby, Python or similar) where you can 'POST' images to the server. With the API frontend, you can also do validation to ensure that only valid images are being uploaded and all nefarious stuff is thrown away. Then, in your iOS app, you can set up code to interact with your API frontend and send the actual images which will then be stored on your server.
This is a fairly conceptual idea rather than an absolute implementation idea. It does require some thinking/reading and more setup/coding on the server side.
Edit: Just to add, if you only want a central location to store/get your images without controlling it on a per user basis then you may want to look into Amazon S3 as a File Server.

Resources