加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

ruby-on-rails – 回形针接受生产的jpg和png

发布时间:2020-12-17 03:43:36 所属栏目:百科 来源:网络整理
导读:我在我的Rails应用程序中使用PaperClip插件,如下所示: has_attached_file :photo,:styles = {:small = '64X64',:medium = '250X250'},:url = "/assets/user_photos/:id/:style/:basename.:extension",:path = ":rails_root/public/assets/user_photos/:id/:
我在我的Rails应用程序中使用PaperClip插件,如下所示:

has_attached_file :photo,:styles => {:small => '64X64>',:medium => '250X250>'},:url  => "/assets/user_photos/:id/:style/:basename.:extension",:path => ":rails_root/public/assets/user_photos/:id/:style/:basename.:extension"
#  validates_attachment_presence :photo
  validates_attachment_content_type :photo,:content_type => ['image/jpeg','image/png','image/gif']
  validates_attachment_size :photo,:less_than => 1.megabytes

它在开发上运行良好(Mac OSX Mongrel).但是当我把它投入生产时(Linux Debian Apache / Passenger)它只接受.gif并且我得到以下错误:.png和.jpg:

Photo /tmp/stream20091028-20066-1t1a0oz-0 is not recognized by the 'identify' command.
 Photo /tmp/stream20091028-20066-1t1a0oz-0 is not recognized by the 'identify' command.

我尝试添加以下行作为一些教程建议,但它没有帮助!

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

解决方法

在生产服务器上,尝试运行:

which identify

这应该为您提供ImageMagick标识二进制文件的路径 – 如果不是,您没有安装ImageMagick或者它不在您的路径中.

如果它返回类似“/usr/bin/identify”的内容,那么您需要将production.rb环境文件中的Paperclip选项设置为:

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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读