Class: Gitlab::Utils::MimeType

Inherits:
Object
  • Object
show all
Defined in:
lib/gitlab/utils/mime_type.rb

Class Method Summary collapse

Class Method Details

.from_io(io) ⇒ Object


10
11
12
13
14
15
# File 'lib/gitlab/utils/mime_type.rb', line 10

def from_io(io)
  return unless io.is_a?(IO) || io.is_a?(StringIO)

  mime_type = File.magic(io, Magic::MIME_TYPE)
  mime_type == 'inode/x-empty' ? nil : mime_type
end

.from_string(string) ⇒ Object


17
18
19
20
21
# File 'lib/gitlab/utils/mime_type.rb', line 17

def from_string(string)
  return unless string.is_a?(String)

  string.type
end