Tuesday, 26 May 2020

Arvind Vyas: Photos upload in background with combination of ra...

Arvind Vyas: Photos upload in background with combination of ra...: It's easy to upload the photo with rails into the background. But when we talk about a platform like Heroku It uses to be very hard t...

Photos upload in background with combination of rails and HEROKU

It's easy to upload the photo with rails into the background.

But when we talk about a platform like Heroku It uses to be very hard to do this.

Why it is hard to upload a photo into Heroku into the background.

   Limitation of Heroku
    - Temp path can not be the same if you are using multiple dynos.
    - After restarting the application temp path use to change.
    - Application use to start at a particular time interval


How we upload image into the background
- We use to save that into the temp folder and we process that photo into the background  by accessing that temp folder into the background via sidekiq or active job etc. But when we talk about Heroku they don't provide fix temp path than how do we process image ?????


So what we found it we convert the photo into blob / base64 object when someone tried to upload and in the controller, we pass that photos block inside the Redis cache with some key-value pair and we send the request into the background and process that Redis cache into the background and save that image and delete the cache for Heroku.

              If anyone has any issue to understand a comment or mail me I will try to make you guys understand if anyone also has better solution post the link to me or send me.

Ruby on Rails 6 Tutorial: Build your First Rails 6 App



Installing Ruby 2.6.2

You can install Ruby 2.6.2 using RVM.

the following command:

$ rvm install 2.6.2


if you want you can create gemset with the command 

rvm gemset create rails6proj
rvm use gemset rails6proj


Install bundler gem to bundle the gems

gem install bundler


Than you can create rails 6 project with the below command


$ rvm install 2.6.2 


$ rails _6.0.3.1_ new my_first_rails6_proj





the above commands teach us if i want to create new rails version application than I just need to pass the version of rails app

rails _version_ new yourappname 

than
cd my_first_rails6_proj 

bundle install to install all the gems inside your gemset

now your rails6 project is ready to work