I'm currently working on uploading multiple images to Cloudinary as part of a form. The problem is the Cloudinary uploader only allows uploading images 1 at a time, so the post request is extremely slow when I upload images like the following:
params[:photos].each do |_, photo|
uploaded_photo = Cloudinary::Uploader.upload(photo.tempfile)
photo = Photo.new(property: @property, public_id: uploaded_photo[:public_id.to_s])
photo.save
end
The images are associated with a property, so having multiple images is very important. I've tried running the uploads in parallel with the Parallel gem, but it just caused my server to freeze up for some unknown reason.
I've also toyed with the idea of uploading images to Cloudinary as they are selected on the form, and then purging any unused images in a job at some undetermined interval.
How would you guys recommend uploading multiple images to cloudinary as part of a model?