我有一种方法可以在 Carrierwave 中复制图像,但Validation failed: Image could not download file
在运行时收到错误消息。它会创建一份 Invoice 副本,然后遍历它的关联图像,将它们设置为 remote_image_url 并重新上传它们。
我认为这与图片网址末尾有 AccessKey 信息这一事实有关。任何的想法?
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