如何添加已经存储在S3上,以carrierwave由同一个数据存储备份文件? [英] how do I add files already stored on s3 to carrierwave backed by same datastore?

查看:131
本文介绍了如何添加已经存储在S3上,以carrierwave由同一个数据存储备份文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经有文件在我S3,这是通过FTP上传,而我只是想将其连接到我的模型,它允许上传通过CarrierWave,如果我使用的是同一个桶来存储我上传的文件通过CarrierWave和那些我通过FTP上传,有没有办法只赋予该文件本身是通过CarrierWave的依恋策略处理的S3密钥文件(新的)相关的记录(通过模型)?

I already have files in my s3, which were uploaded via FTP, and I'd just like to attach them to my models, which allow upload via CarrierWave, if I'm using the same bucket to store the files I upload via CarrierWave and the ones I upload via FTP, is there a way to just assign the s3 key for the file to the (new) associated record (via a model) where the file itself is handled via CarrierWave's attachment strategy?

推荐答案

假定你已经创建缩略图,并且可以存储在S3的正确目录中的文件,你可以简单地说:

Assuming you have the thumbnails already created, and can store the files in the correct directory on S3, you could simply:

@user.update_column(:image, "your-image-name.png")

这不会执行任何回调,并carrierwave将承担所有的处理已经完成。

This will not execute any callbacks, and carrierwave will assume all processing has already been completed.

这是一个很大的假设,虽然如此,你在现实中,这将可能无法正常工作。

That's a lot of assumptions though, so this would likely not work for you in reality.

这篇关于如何添加已经存储在S3上,以carrierwave由同一个数据存储备份文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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