Tuesday 26 May 2020

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.

No comments:

Post a Comment