how do I add files already stored on s3 to carrier

2019-05-09 03:35发布

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?

1条回答
家丑人穷心不美
2楼-- · 2019-05-09 04:25

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")

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.

查看更多
登录 后发表回答