这是我的错误。这是一个回滚交易
Gemfile
:
gem 'ckeditor', '~> 4.1', '>= 4.1.6'
gem 'paperclip', '~> 5.1'
我的请求日志显示
Started POST "/ckeditor/pictures?qqfile=Knipsel.png" for ::1 at 2017-03-21 15:50:26 +0100
Processing by Ckeditor::PicturesController#create as */*
Parameters: {"qqfile"=>"Knipsel.png"}
Command :: file -b --mime "C:/Users/MyName/AppData/Local/Temp/e85eb525e3b5cf46d5c8270aecfc401b20170321-4468-1lbl7wa.png"
[paperclip] Content Type Spoof: Filename Knipsel.png (image/png from Headers, ["image/png"] from Extension), content type discovered from file command: . See documentation to allow this combination.
(0.0ms) begin transaction
Command :: file -b --mime "C:/Users/MyName/AppData/Local/Temp/e85eb525e3b5cf46d5c8270aecfc401b20170321-4468-1bmn28u.png"
[paperclip] Content Type Spoof: Filename Knipsel.png (application/octet-stream from Headers, ["image/png"] from Extension), content type discovered from file command: . See documentation to allow this combination.
**(0.0ms) rollback transaction**
Completed 200 OK in 100ms (Views: 0.1ms | ActiveRecord: 0.0ms)
答案 0 :(得分:0)
Paperclip在允许将文件附加到模型之前验证mime类型。 浏览器通常会发送一个mime类型(它认为文件是什么),在你的情况下,它是' image / png'对于第一个文件和' application / octet-stream'为第二个文件。 但是因为mime类型欺骗是一种东西,回形针试图通过运行'文件来确定mime类型本身。命令对文件。在您的情况下,该命令返回两个文件的空字符串:
, content type discovered from file command: . See documentation to allow this combination.
'命令之间的空格:'和'。'是文件命令返回的内容。
我的猜测是:您在Windows上运行并且没有安装它,或者无法找到它。关注these instructions for exactly that case on the paperclip website。