我如何下载远程图像(http协议,URL位于image_remote_url属性中)并通过Paperclip将其保存为S3的附件?回形针S3下载远程图像
class Product < ActiveRecord::Base
require 'open-uri'
attr_accessor :image_remote_url
has_attached_file :photo,
:storage => :s3,
:s3_credentials => "#{RAILS_ROOT}/config/s3.yml",
:path => ":class/:id/:style.:extension",
:bucket => "my_bucket",
:styles => {
:icon => "32x32#",
}
def fetch_image
# how should this method look ?
end
end
方法“fetch_image”应该怎么看?