0
votes

I am using Carrierwave + carrierwave_backgrounder + Sidekiq + Heroku to upload images. The upload works fine. When the upload form is submitted, I need to display the uploaded image, but background job is still processing it, so the page only displays the file name, I have to wait the background job is done, refresh the page to see it. How can I display a temp uploaded image when the page finish loading?

I know I can config the cache_dir to store a tmp image and will be deleted afterwards, like this:
def cache_dir
"#{Rails.root}/tmp/uploads"
end

Can I render this tmp image? If so, how do I render this in the view? I want to avoid using default_url in the uploader

I am using process_in_background :avatar in the model

Thanks!!

1
I doubt there is something like it with that I presume ur best bet (perhaps you know it ) default_url also make sure you set move_to_cache move_to_store could improve ur background processing experience because seem like u r file are quite largeViren

1 Answers

2
votes

You should be able to define the default_url method in your uploader class.

Ex:

class MyUploader < CarrierWave::Uploader::Base
  def default_url
    "/images/fallback/" + [version_name, "default.png"].compact.join('_')
  end
end