Paperclip适用于图像,但不适用于PDF文件



我有一个使用Paperclip的Rails 3.1应用程序。它在本地运行得很好,但在服务器上我似乎无法上传PDF。PNG和JPG图像完美工作。

当试图用PDF附件保存记录时,我得到以下错误:

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.

我已经检查了Apache日志,其中显示了以下内容:

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

我不知道问题出在哪里,Imagemagik安装在服务器上(运行Ubuntu),图像文件运行良好。我看不到任何文件大小限制的参考,所以我不认为是这样。

感谢您的帮助!

编辑:

只是为了确认我已经查找了"识别"不识别等问题,并尝试将以下内容添加到我的production.rb环境文件中:

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

但这并没有什么区别。

对于任何感兴趣的人,我采取了以下步骤来纠正这一问题。请注意,我不需要图像大小调整、缩略图等。

我更改了如下的模型代码:

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

到此:

class User < ActiveRecord::Base
  has_attached_file :avatar
end

最新更新