So I didn't realize that I had been saving files and images in production to config.active_storage.service =:local
I want it to match my staging which is config.active_storage.service =:digitalocean_spaces
The problem is when I switch it I break all the links to the old images. Question is how do I migrate those files into my digitalocean_spaces or even get them out of active_storage.serivce local to upload them into my digital oceans space
You can now use Mirror Service :
You can keep multiple services in sync by defining a mirror service. A mirror service replicates uploads and deletes across two or more subordinate services.
A mirror service is intended to be used temporarily during a migration between services in production. You can start mirroring to a new service, copy pre-existing files from the old service to the new, then go all-in on the new service.
You'll also need a custom script to sync your files between the mirrors. Basically, you have to call mirror_later
on each blob (works on Rails 6.1+):
ActiveStorage::Blob.all.each do |blob|
blob.mirror_later
end
Read more examples and approaches in the following answer: How to sync new ActiveStorage mirrors?
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.