Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 651
Ben West Avatar asked Feb 16 '23 07:02

Ben West


1 Answers

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.

like image 128
Jesse Wolgamott Avatar answered Mar 15 '23 23:03

Jesse Wolgamott