-
Notifications
You must be signed in to change notification settings - Fork 1.7k
How to: Recreate and reprocess your files stored on fog
rosshale edited this page Apr 2, 2012
·
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.all.each do |ym|
ym.your_uploader.cache_stored_file!
ym.your_uploader.retrieve_from_cache!(ym.your_uploader.cache_name)
ym.your_uploader.recreate_versions!
ym.save!
end
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.
Good luck!