ast*_*nic 2 ruby-on-rails amazon-s3 paperclip
我如何下载远程图像(http协议,url在image_remote_url属性中)并通过Paperclip将其保存为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
Run Code Online (Sandbox Code Playgroud)
"fetch_image"方法应该怎么样?
这是一个页面链接,可以准确地解释您的需求.
http://trevorturk.wordpress.com/2008/12/11/easy-upload-via-url-with-paperclip/
我在自己的网站上成功实现了它.
| 归档时间: |
|
| 查看次数: |
3812 次 |
| 最近记录: |