我使用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/"
ImageMagick似乎已经安装并正确设置:
$ which Magick-config
/opt/local/bin/Magick-config
谢谢!
which identify
、locate identify
或find / -name identify
会返回什么? - Eric