【发布时间】:2014-03-02 18:45:18
【问题描述】:
我正在尝试导入数千个项目,其中大多数项目使用相同的图像。我想在上传图像之前检查是否已经存在同名的图像,这样我就可以节省时间和资源。我使用亚马逊 s3 作为存储。我似乎无法在文档中找到任何关于它的内容。我知道我可以做类似 image.exists 的事情?但是我在模型中怎么做才能不上传图像但仍然将数据库中的所有内容设置为指向现有图像。
Rails 3.2.12
回形针 3.2.1
validates_attachment_content_type :image, :content_type => ['image/jpeg', 'image/png', 'image/gif', 'image/pjpeg']
has_attached_file :image,
:storage => :s3,
:s3_credentials => "#{Rails.root.to_s}/config/s3.yml",
:path => "images/:attachment/:style/:filename",
:styles => { :original => '64x64', :small => '32x32' }
【问题讨论】:
标签: ruby-on-rails ruby ruby-on-rails-3 amazon-s3 paperclip