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

ruby-on-rails – Paperclip – 图像上传错误:“’identify’命

发布时间:2020-12-17 02:59:15 所属栏目:百科 来源:网络整理
导读:我使用Rails 3和paperclip.我的逻辑允许用户上传图像.除非用户选择不是图像的文件,否则该工作正常. 例如,如果用户选择文本文件,验证通过但最终会出现此错误: 5 errors prohibited the profile update:Profile pic content type is not one of image/jpeg,im
我使用Rails 3和paperclip.我的逻辑允许用户上传图像.除非用户选择不是图像的文件,否则该工作正常.

例如,如果用户选择文本文件,验证通过但最终会出现此错误:

5 errors prohibited the profile update:

Profile pic content type is not one of image/jpeg,image/png,image/gif
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-17xuiu4-0.js is not recognized by the 'identify' command.

至少第一个错误是指文件类型.但是如果用户上传了一些更具体的文件,比如.PXM,那么Rails表现得很奇怪,并显示:

4 errors prohibited the profile update:

Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command.
Profile pic /var/folders/lF/lF0Ne5vGFj44kV54W3zBdU+++TI/-Tmp-/stream20101118-229-1scwkg7-0.pxm is not recognized by the 'identify' command.

有谁知道这里发生了什么?我的模型中有以下代码:

validates_attachment_content_type :profile_pic,:content_type=>['image/jpeg','image/png','image/gif']

…以及此回形针初始化程序:

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

ImageMagik似乎已正确安装和设置:

$which Magick-config
/opt/local/bin/Magick-config

谢谢!

解决方法

我在Paperclip和Rails 2.3.8中遇到了同样的问题. 在Model的has_attached_file声明中,删除任何非图像文件的:styles.

(编辑:李大同)

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

    推荐文章
      热点阅读