如何使用 Paperclip 复制文件 [英] How to copy a file using Paperclip

查看:51
本文介绍了如何使用 Paperclip 复制文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有谁知道一种使用 S3 存储使用 Paperclip 复制文件的方法吗?在我尝试自己编写之前,我只是想确保没有办法做到这一点.谢谢

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

推荐答案

在对回形针进行了一番折腾之后,我想通了.复制文件简直太简单了!

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

这也适用于亚马逊 s3.甜

This also works great with amazon s3. Sweet

这篇关于如何使用 Paperclip 复制文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆