I'm trying to rename a lot of files in s3--changing the current paperclip has_attached_file
:path
from stuff/:id_:updated_at_:style.:extension
to stuff/:id_:counter_:style.:extension
, where :counter
is a field in the same model as the image.
I haven't the foggiest on how to rename all the files--preferably in a rake task.
Incidentally, I'll be incrementing :counter
each time a new file is saved to the record.
This is Rails 3 and the latest Paperclip as of this posting.
Any ideas?
Thanks!
Here's my solution:
It just goes through all the files in the bucket and renames them according to this new schema. I set the :counter field in the Paperclip path to default to 1, thus the
_1_
in the new file name.Works like a charm!
Give paperclip's refresh rake task a try. I've used it to generate new styles and I'm guessing it will pick up on your path change as well?
https://github.com/thoughtbot/paperclip/wiki/Thumbnail-Generation