Ruby on rails 无法使用Ruby on Rails中的曲别针ffmpeg从iPhone上载视频

Ruby on rails 无法使用Ruby on Rails中的曲别针ffmpeg从iPhone上载视频,ruby-on-rails,ruby-on-rails-3,ruby-on-rails-4,ffmpeg,ruby-on-rails-3.2,Ruby On Rails,Ruby On Rails 3,Ruby On Rails 4,Ffmpeg,Ruby On Rails 3.2,当我从iPhone上传视频时,出现以下错误: Command :: PATH=/usr/bin/:$PATH; file -b --mime '/tmp/6da355e988ec841811d8803dfd5cf44c20150513-8103-b4lkam.MOV' [paperclip] Content Type Spoof: Filename IMG_2637.MOV (["video/quicktime"]), content type discovered from file comm

当我从iPhone上传视频时,出现以下错误:

Command :: PATH=/usr/bin/:$PATH; file -b --mime '/tmp/6da355e988ec841811d8803dfd5cf44c20150513-8103-b4lkam.MOV'
[paperclip] Content Type Spoof: Filename IMG_2637.MOV (["video/quicktime"]), content type discovered from file command: inode/x-empty. See documentation to allow this combination.
(0.6ms)  ROLLBACK
Completed 400 Bad Request in 58ms (Views: 0.9ms | ActiveRecord: 5.0ms)
(当我从桌面上传相同的视频时,这一点非常有效。)

我使用了gems
“回形针”、“~>4.1”
“回形针ffmpeg”

在我的视频模型中:

validates_attachment_content_type :student_video, content_type: /\Avideo\/.*\Z/
也试过了

validates_attachment_content_type :student_video, :content_type => ['video/x-   
#                                        msvideo', 'video/avi', 'video/quicktime', 'video/3gpp', 'video/x-ms-
#                                        wmv', 'video/mp4', 'flv-application/octet-stream', 'video/x-
#                                        flv', 'video/mpeg', 'video/mpeg4', 'video/x-la-asf', 'video/x-ms-asf']

但是我得到了同样的错误。

看起来像是回形针认为你在上传伪造的媒体

我在这里找到了一个解决方法:


您基本上是在对Paperclip的MediaTypeSpoofDetector类进行修补,以确保它不会检查欺骗行为。

谢谢。我尝试了上述解决方案,但结果是一样的,我可以上传视频如上所述。
require 'paperclip/media_type_spoof_detector'
module Paperclip
  class MediaTypeSpoofDetector
    def spoofed?
      false
    end
  end
end