dannymcc
dannymcc

Reputation: 3814

Paperclip is working for images but not for PDF files

I have a Rails 3.1 application thats using Paperclip. It's working perfectly locally but on the server I can't seem to get PDF uploads working. PNG and JPG images work perfectly.

When trying to save a record with a PDF attachment I get the following error:

Avatar /tmp/stream20120110-10803-1whykjx-0.pdf is not recognized by the 'identify' command.
Avatar /tmp/stream20120110-10803-1whykjx-0.pdf is not recognized by the 'identify' command.

I have checked the Apache logs which show the following:

sh: gs: not found
identify: Postscript delegate failed `/tmp/stream20120110-5508-or6g2v-0.pdf': No such file or directory @ pdf.c/ReadPDFImage/634.
sh: gs: not found
identify: Postscript delegate failed `/tmp/stream20120110-5508-or6g2v-0.pdf': No such file or directory @ pdf.c/ReadPDFImage/634.
cache: [POST /courses] invalidate, pass
sh: gs: not found
identify: Postscript delegate failed `/tmp/stream20120110-5508-vgyyz8-0.pdf': No such file or directory @ pdf.c/ReadPDFImage/634.
sh: gs: not found
identify: Postscript delegate failed `/tmp/stream20120110-5508-vgyyz8-0.pdf': No such file or directory @ pdf.c/ReadPDFImage/634.
cache: [POST /courses] invalidate, pass

I can't work out where the issue is, Imagemagick is installed on the server (which is running Ubuntu) and image files work perfectly. I can't see any reference of a file size limit so I don't think it's that.

Any help is appreciated!

EDIT:

Just to confirm I have looked up the issue of 'identify' not recognising etc. and have tried adding the following to my production.rb environment file:

Paperclip.options[:command_path] = "/usr/bin/identify"

but that made no difference.

Upvotes: 0

Views: 955

Answers (1)

dannymcc
dannymcc

Reputation: 3814

For anyone that's interested I took the following steps to rectify this. Note that I don't need image resizing, thumbnails etc.

I changed the model code that was like this:

class User < ActiveRecord::Base
  has_attached_file :avatar, :styles => { :medium => "300x300>", :thumb => "100x100>" }
end

to this:

class User < ActiveRecord::Base
  has_attached_file :avatar
end

Upvotes: 1

Related Questions