How to copy a file using Paperclip

后端 未结 1 1600
我在风中等你
我在风中等你 2020-12-17 09:42

Does anyone know of a way to copy files with Paperclip using S3 for storage? Before I try to write my own, I just wanted to make sure there wasn\'t already a way to do this.

相关标签:
1条回答
  • 2020-12-17 10:32

    After some more messing around with paperclip, I figured it out. It's ridiculously simple to copy files!

    # Stupid example method that just copies a user's profile pic to another user.
    def copy_profile_picture(user_1, user_2)
      user_2.picture = user_1.picture
      user_2.save # Copied the picture and we're done!
    end
    

    This also works great with amazon s3. Sweet

    0 讨论(0)
提交回复
热议问题