Search code examples
ruby-on-railscarrierwaveimage-uploadingsidekiq

Rails: How to hook callbacks (Update UI view) when Sidekiq finish processing the job


I am using Carrierwave, Carrierwave_backgrounder and Sidekiq to upload image in the background to S3, in my model I used store_in_background :avatar. The image get uploaded correctly.

My problems is that I need to display the uploaded image after the page is refreshed, but it only displays the image's file name as string, I assume it is because the background job is still processing the upload. Is there a way I can gets notified when the background job is done, so I can update the view? Or I can get a tmp uploaded image from the upload request and display it in the response?

Or do I have to write an observer to check the Redis database to see if the job has been done, then update the view?

Thanks


Solution

  • Just found that Carrierwave creates tmp image inside the public/uploads directory. I am now using #{image}_tmp to get the origin image path.