Paperclip renaming files after they're saved

前端 未结 9 1478
情书的邮戳
情书的邮戳 2020-12-07 23:34

How do I rename a file after is has been uploaded and saved? My problem is that I need to parse information about the files automatically in order to come up with the file

9条回答
  •  青春惊慌失措
    2020-12-07 23:54

    To add to @Voyta's answer, if you're using S3 with paperclip:

    (record.image.styles.keys+[:original]).each do |style|
      AWS::S3::S3Object.move_to record.image.path(style), new_file_path, record.image.bucket_name
    end
    
    record.update_attribute(:image_file_name, new_file_name)
    

提交回复
热议问题