carrierwaveuploader / carrierwave

Classier solution for file uploads for Rails, Sinatra and other Ruby web frameworks
https://github.com/carrierwaveuploader/carrierwave
8.78k stars 1.66k forks source link

updating carrierwave attribute after storing another file at same location #2622

Closed sgrverma24 closed 1 year ago

sgrverma24 commented 2 years ago

I have a usecase, where I have uploaded a file using carrierwave fog-google on GCS bucket. However using some other code, I am processing the same file then re-uploading it after changing size and name from google-cloud-storage APIs. Now at the same location we have two files. One is original and other one is processed file.

Here my query is, how to update the new file attributes in carrierwave active record stored in mongoDB for the original file. I want to update the file location, url, name, path all other attributes etc from the original file to processed file.

Is there any way we can achieve it using carrierwave functionality. Any help would be appriciated.

mshibuya commented 1 year ago

There's no ready-made way to do so. What's stored in the ActiveRecord column is just a String value, you can use AR's #update_columns to update it in a desired way without interacting with CarrierWave.