2

While i am migrating from Ruby 1.8.7 to 1.9.3, facing one issue on Paperclip photo upload.

We have Paperclip configured, with s3 as a store. It works fine when i run rails server using 1.8.7, but its not uploading the file (without any error) with 1.9.3.

Please have a look at configuration and log.

paperclip config:

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

log when uploading image

[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'

Share your ideas on this, i am new to Ruby. do i missed some configuration? Because its already working on 1.8.7, that should not be the case.

Update:

Using Paperclip 2.7.0, Rails 3.0.11 and Ruby 1.9.3

Parth
  • 1,281
  • 8
  • 17

1 Answers1

2

I found the solution after i checked the exception thrown while doing model.save!.

Basically, the content type validation was failing for the uploaded image file. This was working with paperclip 2.70, but for >3.0 version we need to change as following.

#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/

So now, image has been uploaded successfully on amazon s3 server.

Reference

Validate Attachment Content Type Paperclip

Community
  • 1
  • 1
Parth
  • 1,281
  • 8
  • 17