2012-01-10 28 views
0

我有一个使用回形针的Rails 3.1应用程序。它在本地完美运行,但在服务器上我似乎无法使PDF上传正常工作。 PNG和JPG图像完美地工作。回形针正在处理图像,但不能处理PDF文件

当试图保存记录以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 

我不能工作问题出在哪里,Imagemagick安装在服务器上(运行Ubuntu),图像文件完美地工作。我看不到任何文件大小限制的参考,所以我不认为是这样。

任何帮助表示赞赏!

编辑:

只是为了确认我已经抬头的问题,“识别”不能识别等,并尝试添加以下到我的production.rb环境文件:

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

但没有区别。

+1

看起来像它的尝试运行ghostscript作为过程的一部分,也许是缩略图。也许一个自定义类跳过这一步?我会从回形针代码开始,看看默认的PDF处理程序是干什么的。也可以是一个配置。 – 2012-01-10 21:14:58

+0

明白了,我不需要缩略图或类似的东西,所以我从回形针代码中删除它。谢谢! – dannymcc 2012-01-10 21:16:59

回答

1

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

我改变了这一切是这样的型号代码:

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

这样:

class User < ActiveRecord::Base 
    has_attached_file :avatar 
end