I have a method to duplicate images in Carrierwave but receive the error Validation failed: Image could not download file when I run it. It creates a copy of Invoice, then goes through it’s associated images, sets them as a remote_image_url and should re-upload them.
I believe it has something to do with the fact that there’s AccessKey information at the end of an image url. Any idea?
def self.duplicate_it(invoice)
new_invoice = invoice.dup
new_invoice.save
if invoice.images.any?
invoice.images.each do |i|
temp_image = i.image
new_image = Image.new(:remote_image_url => temp_image.to_s, :order_id => new_invoice.id)
new_image.save!
end
end
end
This worked