【发布时间】:2010-04-15 09:22:10
【问题描述】:
我一直在寻找如何解决这个问题,但找不到任何真正可行的解决方案。
用户模型:
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/识别
指定命令路径并不能解决问题:
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
如果有人解决了同样的问题以及如何解决,请告诉我。非常感谢。
【问题讨论】:
标签: ruby-on-rails ruby paperclip