I have a model with a avatar paperclip attach. It has now a plain standard path
has_attached_file :avatar,
:path => "/:id-:style-:filename"
Which I need to move into an obfuscated one
has_attached_file :avatar,
:path => "/:id-:hash.:extension"
:hash_secret => 'asecuresecret'
Everything’s working fine with new images, but how do I migrate the existing files stored in S3 to the new path format, ie rename them?
I’m using paperclip 2.7 and Rails 3.2
Thanks !!!
This rake task should do the trick. I tried it with aws-sdk 1.5.2 and ruby 1.9.3p194.
The
new_keyshould map to your new paperclip path. Don’t forget to set:aclaccording to your needs.The original file should be deleted manually or using a similar task, once you are sure the new file is correct.