def sniff_mime(content)
      m = MimeMagic.by_magic(content)
      return if m.nil?

      # Overwrite incorrect mime types
      case m.type.to_s
      when 'application/xhtml+xml'
        return 'text/html'
      when 'text/x-csrc'
        return 'text/css'
      end

      m.type
    rescue
      nil
    end
def sniff_mime(content)
      m = MimeMagic.by_magic(content)
      return if m.nil?

      # Overwrite incorrect mime types
      case m.type.to_s
      when 'application/xhtml+xml'
        return 'text/html'
      when 'text/x-csrc'
        return 'text/css'
      end

      m.type
    rescue
      nil
    end
Guess content type based on magic bytes

 @param [String] content File contents

 @return [String] content-type value