How to copy a file using Paperclip

£可爱£侵袭症+ 提交于 2019-12-18 04:32:13

问题


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


回答1:


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



来源:https://stackoverflow.com/questions/2739839/how-to-copy-a-file-using-paperclip

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!