2012-01-10 30 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