19

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. Thanks

CalebHC
  • 4,998
  • 3
  • 36
  • 42

1 Answers1

28

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

CalebHC
  • 4,998
  • 3
  • 36
  • 42
  • 3
    The problem here, though, would be that if you have any kind of media editing or deleting, when user 1 edits or deletes their picture, user 2 will get those changes on their profile, right? – Cosmin Atanasiu Jan 04 '14 at 00:50