我一直在寻找如何解决这个问题,但是没有找到任何真正有效的解决方案。
用户模型:
validates_attachment_content_type :avatar, :content_type => ['image/jpeg', 'image/pjpeg', 'image/x-png', 'image/png', 'image/gif']
当上传无效文件类型时,会出现不必要的错误提示:
Avatar /tmp/sample,23283,0.txt is not recognized by the 'identify' command.
服务器详情: Ubuntu和Debian
它们识别结果为 /usr/bin/identify
指定命令路径不能解决问题:
Paperclip.options[:command_path] = "/usr/bin"
有什么想法吗?
我查看了geometry.rb文件,似乎有些问题。
def self.from_file file
file = file.path if file.respond_to? "path"
geometry = begin
Paperclip.run("identify", %Q[-format "%wx%h" "#{file}"[0]])
rescue PaperclipCommandLineError
""
end
parse(geometry) ||
raise(NotIdentifiedByImageMagickError.new("#{file} is not recognized by the 'identify' command."))
end
如果有人解决了相同的问题,请告诉我是如何解决的。非常感谢。