我一直在寻找如何解决这个问题,但找不到任何真实有效的解决方案.
用户模型:
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
如果有人解决了同样的问题,请告诉我.非常感谢.