我如何下載遠程圖像(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」應該怎麼看?