Search code examples
ruby-on-rails-3image-processingamazon-s3carrierwavefog

If I edit an image in a rake task with RMagick, how do I manually save it back to S3?


I have an app where people can upload pics, they're saved on S3 using the Carrierwave & Fog combo.

I'm rewriting the app, so in a rake task I need to loop through all images, resize/crop them (with RMagick), and save them back to S3 where they originally lived. I feel like I'm missing something obvious, is there a succinct way to do this? I don't want to have to get another S3 gem if I can do this with Fog which I already have available to me.

If anyone can point me in the right direction I would appreciate it, thanks!

EDIT

Using these instructions How can I use fog to edit a file on s3? I managed to get a handle on the file from S3... sort of. It's of type Fog::Storage::AWS::File, but how do I get a handle on the actual image so I can edit it?


Solution

  • The answer was actually so simple, I didn't realize CarrierWave could recreate and re-save all my images with the user.avatar.recreate_versions! method!