我使用的是 CentOS。我有回形针 gem 最新版本。我已经阅读过有关欺骗的内容,但问题仍然存在!我什至尝试了旧版本 3.5.2,但仍然出现错误。我正在远程服务器上执行此操作!不知道是否需要重新启动apache之类的? 救命!
I, [2014-04-09T18:41:45.251093 #5841] INFO -- : Command :: file -b --mime-type '/tmp/5b42e9da0503617fea7f216d7860262920140409-5841-k6wzm6'
I, [2014-04-09T18:41:45.257581 #5841] INFO -- : [paperclip] Content Type Spoof: Filename justdoit.jpeg (["image/jpeg"]), content type discovered from file command: . See documentation to allow this combination.
添加选项后,现在我得到了这个:
I, [2014-04-09T21:20:46.797630 #11118] INFO -- : Started GET "/system/bboys/avatars/000/000/001/medium/Casper_Family_11.jpg?1397064045" for 90.197.101.127 at 2014-04-09 21:20:46 +0400
F, [2014-04-09T21:20:46.799580 #11118] FATAL -- :
ActionController::RoutingError (No route matches [GET] "/system/bboys/avatars/000/000/001/medium/Casper_Family_11.jpg"):
vendor/bundle/ruby/2.0.0/gems/actionpack-4.0.0/lib/action_dispatch/middleware/debug_exceptions.rb:21:in `call'
最佳答案
如果您不担心 jpeg/jpg 文件的欺骗检查,您可以设置回形针选项:
Paperclip.options[:content_type_mappings] = { jpeg: 'image/jpeg', jpg: 'image/jpeg' }
这将绕过file -b --mime-type
命令。
关于ruby-on-rails - 回形针 gem 欺骗错误?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22966481/