Mobile upload file to S3 using a Rails Rest API - ruby-on-rails

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!

Related

When I should upload files directly to amazon S3

I've seen many posts talking about direct uploading to amazon S3 but none of them tell when we should really do that !
Is "direct upload to S3" always better than uploading to S3 via Rails app using gems like paperclip or carrierwave... ?
And when I should use direct upload vs normal upload to S3 ?
Uploading directly to Amazon S3 has the benefit of reducing load on your back-end web servers (for both CPU and bandwidth).
It is great for mobile apps that can call the Amazon S3 API directly, but is also applicable to web pages that can upload via a POST to Amazon S3.

Scaling user image uploads on Heroku with Carrierwave

I have a Rails app on Heroku that seems to be having trouble scaling the way I want it to. In the app, a user can upload multiple nested images to an invoice. Based on my research, it seems that this ties up a Heroku web dyno (I'm running 3) until it's done uploading. I've looked into Carrierwave Direct so that a web dyno isn't used but it doesn't seem that this is compatible with a nested model. Does anyone have any other suggestions?
Don't upload images to Heroku. It will lock your entire web server. Instead, use a jQuery library (https://github.com/blueimp/jQuery-File-Upload) to upload directly to Amazon S3 from the client side.

iOS Client + Rest API to upload photos

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.

Uploading and storing images remotely?

I'm building a rails application where users may want to upload images occasionally. Is there a way to have the users seamlessly upload the images to a remote host, like imgur, and store the URLs to the images in my database so that they can be displayed when needed?
I want to give the impression that they are uploading images directly to the database while actually offloading them to imgur. Is there a gem that does this, or does anybody have a good way to implement this?
Thanks.
Not sure about imgur, but if what you want is simply storing the images on the remote server, I think s3 + paperclip can be a good choice.
aws sdk: http://aws.amazon.com/articles/8621639827664165
paperclip: https://github.com/thoughtbot/paperclip
Using "gem 'carrierwave'" and "gem 'fog'" to upload to Google Cloud Storage or Amazon S3 is probably your best option.
http://railscasts.com/episodes/383-uploading-to-amazon-s3

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

Resources