升级1.8.7到1.9.3,回形针s3上传不起作用

当我从Ruby 1.8.7迁移到1.9.3时,面临Paperclip照片上传的一个问题。

我们配置了Paperclip,s3作为商店。 当我使用1.8.7运行rails服务器时它工作正常,但它没有上传1.9.3的文件(没有任何错误)。

请查看配置和日志。

回形针配置:

has_attached_file :pic, :styles => { :thumb => "100x100#", :one => "118x100#", :two => "222x149#", :three => "460x345#", :popup => "480x360#" }, :storage => :s3, :s3_credentials => Settings.amazon_s3.to_hash, :path => ":attachment/:id/:style/:filename", :bucket => Settings.amazon_s3.my_bucket 

上传图片时记录

 [paperclip] Duplicate URL for photo with /system/:attachment/:id/:style/:filename. This will clash with attachment defined in Photo class [paperclip] Duplicate URL for photo with /system/:attachment/:id/:style/:filename. This will clash with attachment defined in User class Command :: identify -format %wx%h '/tmp/stream20120414-20761-hnqjzj.jpg[0]' Command :: convert '/tmp/stream20120414-20761-hnqjzj.jpg[0]' -resize "x100" -crop "100x100+30+0" +repage '/tmp/stream20120414-20761-hnqjzj20120414-20761-1e0nflx' Command :: identify -format %wx%h '/tmp/stream20120414-20761-hnqjzj.jpg[0]' Command :: convert '/tmp/stream20120414-20761-hnqjzj.jpg[0]' -resize "x100" -crop "118x100+21+0" +repage '/tmp/stream20120414-20761-hnqjzj20120414-20761-h7a0ri' Command :: identify -format %wx%h '/tmp/stream20120414-20761-hnqjzj.jpg[0]' Command :: convert '/tmp/stream20120414-20761-hnqjzj.jpg[0]' -resize "x149" -crop "222x149+8+0" +repage '/tmp/stream20120414-20761-hnqjzj20120414-20761-10av65c' Command :: identify -format %wx%h '/tmp/stream20120414-20761-hnqjzj.jpg[0]' Command :: convert '/tmp/stream20120414-20761-hnqjzj.jpg[0]' -resize "x345" -crop "460x345+46+0" +repage '/tmp/stream20120414-20761-hnqjzj20120414-20761-13ixq6o' Command :: identify -format %wx%h '/tmp/stream20120414-20761-hnqjzj.jpg[0]' Command :: convert '/tmp/stream20120414-20761-hnqjzj.jpg[0]' -resize "x360" -crop "480x360+48+0" +repage '/tmp/stream20120414-20761-hnqjzj20120414-20761-g6turu' 

分享你的想法,我是Ruby的新手。 我错过了一些配置吗? 因为它已经在1.8.7上工作,所以不应该这样。

更新:

使用Paperclip 2.7.0,Rails 3.0.11和Ruby 1.9.3

在我检查执行model.save!抛出的exception后,我找到了解决方案model.save!

基本上,上传的图像文件的内容类型validation失败。 这与paperclip 2.70一起使用,但对于> 3.0版本,我们需要更改如下。

 #The old contentType setting is commented out #validates_attachment_content_type :photo, :content_type => ['image/jpeg', 'image/pjpeg', 'image/jpg', 'image/png'] validates_attachment_content_type :photo, :content_type => /image/ 

所以现在,图像已成功上传到amazon s3服务器上。

参考

validation附件内容类型回形针