Skip to content

How to: Recreate and reprocess your files stored on fog

Riley Gelwicks edited this page Mar 17, 2017 · 6 revisions

Recording this here for others with the same issue.

Let's say you're storing your carrierwave files on S3 or some other cloud storage provider through fog.

Let's say you've made some changes to your versions and/or processing of these files and you wish to re-process everything.

With file storage this is simple but with fog it's a bit less straight-forward. The magic incantation is:

YourModel.find_each do |ym| 
    ym.process_your_uploader_upload = true # only if you use carrierwave_backgrounder
    ym.your_uploader.recreate_versions!(:version1, :version2)! 
  rescue => e
    puts  "ERROR: YourModel: #{} -> #{e.to_s}"

The trick here is that when you call retrieve_from_cache!, your_uploader.file becomes a CarrierWave::SanitizedFile where it was previously a CarrierWave::Storage::Fog::File.

Also with carrierwave_backgrounder you need to set process_#{uploader}_upload flag to true, otherwise it won't generate versions.

If processing lots of files and using too much tmp you can call:


Good luck!

Clone this wiki locally
You can’t perform that action at this time.