Sha256: b1bb4b936f649d098756d39bbfd4e3a03cde1c1ae1cf1762b591d2049de5646f

Contents?: true

Size: 672 Bytes

Versions: 29

Compression:

Stored size: 672 Bytes

Contents

# Monkey patches to Ruby on Rails
#
# Use unix file util to prove the content type sent by the browser
class ActionDispatch::Http::UploadedFile
  def initialize_with_magic(*args, &block)
    initialize_without_magic(*args, &block)

    if (unix_file = `which file`.chomp).present? && File.exists?(unix_file)
      `#{ unix_file } -v 2>&1` =~ /^file-(.*)$/
      version = $1

      @content_type =
        if version >= "4.24"
          `#{ unix_file } -b --mime-type #{ @tempfile.path }`.chomp
        else
          `#{ unix_file } -bi #{ @tempfile.path }`.chomp =~ /(\w*\/[\w+-\.]*)/
          $1
        end
    end
  end

  alias_method_chain :initialize, :magic
end

Version data entries

29 entries across 29 versions & 2 rubygems

Version Path
social_stream-0.28.4 base/lib/rails/social_stream.rb
social_stream-base-0.22.4 lib/rails/social_stream.rb
social_stream-0.28.1 base/lib/rails/social_stream.rb
social_stream-base-0.22.1 lib/rails/social_stream.rb
social_stream-0.28.0 base/lib/rails/social_stream.rb
social_stream-base-0.22.0 lib/rails/social_stream.rb
social_stream-0.27.3 base/lib/rails/social_stream.rb
social_stream-0.27.2 base/lib/rails/social_stream.rb
social_stream-base-0.21.2 lib/rails/social_stream.rb
social_stream-0.27.1 base/lib/rails/social_stream.rb
social_stream-base-0.21.1 lib/rails/social_stream.rb
social_stream-0.27.0 base/lib/rails/social_stream.rb
social_stream-base-0.21.0 lib/rails/social_stream.rb
social_stream-0.26.2 base/lib/rails/social_stream.rb
social_stream-base-0.20.2 lib/rails/social_stream.rb
social_stream-0.26.1 base/lib/rails/social_stream.rb
social_stream-base-0.20.1 lib/rails/social_stream.rb
social_stream-0.26.0 base/lib/rails/social_stream.rb
social_stream-base-0.20.0 lib/rails/social_stream.rb
social_stream-0.25.2 base/lib/rails/social_stream.rb