how do I add files already stored on s3 to carrierwave backed by same datastore?

荒凉一梦 提交于 2019-12-07 10:15:45

问题


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:


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.



来源:https://stackoverflow.com/questions/16968658/how-do-i-add-files-already-stored-on-s3-to-carrierwave-backed-by-same-datastore

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