Scaling user image uploads on Heroku with Carrierwave - ruby-on-rails

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.

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.

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!

wordpress edited stylesheet is reset and attached image is gone after a while

I followed this post to setup a wordpress site hosted on Heroku.
As an admin, I edited the stylesheet(style.css) and uploaded some images. It all works and the site is updated successfully. But after a while when I check the site again, our customized codes in the stylesheet and the images uploaded are gone.
Anyone can help me figure out why it happened and how should I fix it?
Find the same question and answer here:
"The problem is because Heroku doesn't allow you to have persistent storage on the Dynos. So initially when you upload the image it'll work but Heroku will sometimes restart your Dyno or move it to some other host (as they constantly shift applications to load balance their servers).
In order to make sure that your images stay online you should use a Wordpress Plugin that uploads to a persistent storage service such as Amazon S3. You could give this plugin a try: Amazon S3 for WordPress
The great thing about using Amazon S3 is that it's free for the first year if you use their Free Tier. You will have some limits but if it's a low traffic site, you shouldn't go beyond them easily."
Wordpress Heroku Featured Images not showing

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

Publishing a Ruby on Rails website using Amazon S3

I've completed my website using a Ruby on Rails framework, which uses a simple database.
I have set up an Amazon S3 account and would like to upload it to this, however I've been told that I would need more than just this to get the website working.
I am COMPLETELY new to uploading RoR websites, so would anyone be willing to talk me through what needs doing/ why?
Amazon S3 is simply for storing static assets, images, css etc. You can run entirely static sites on it ie html but not 'applications'.
You may have misheard - you could use Amazon EC2 which provide you with a virtual server to host your application and run your application.
If you are entirely new to this process then I suggest you investigate the likes of Heroku (heroku.com) EngineYard, BrightBox, Rackspace etc With the first you probably would be able to use their free offering and deployment is simply by Git - there's no system administration involved.

Resources