ruby-on-rails – Paperclip – 图像上传错误:“’identify’命令无法识别.”

ruby-on-rails – Paperclip – 图像上传错误:“’identify’命令无法识别.”,第1张

概述我使用Rails 3和paperclip.我的逻辑允许用户上传图像.除非用户选择不是图像的文件,否则该工作正常. 例如,如果用户选择文本文件,验证通过但最终会出现此错误: 5 errors prohibited the profile update:Profile pic content type is not one of image/jpeg, image/png, image/gifP 我使用Rails 3和paperclip.我的逻辑允许用户上传图像.除非用户选择不是图像的文件,否则该工作正常.

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

5 errors prohibited the profile update:Profile pic content type is not one of image/jpeg,image/png,image/gifProfile 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. 总结

以上是内存溢出为你收集整理的ruby-on-rails – Paperclip – 图像上传错误:“’identify’命令无法识别.”全部内容,希望文章能够帮你解决ruby-on-rails – Paperclip – 图像上传错误:“’identify’命令无法识别.”所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/langs/1288610.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-06-09
下一篇 2022-06-09

发表评论

登录后才能评论

评论列表(0条)

保存