Module: Axlsx::MimeTypeUtils

Defined in:
lib/axlsx/util/mime_type_utils.rb

Overview

This module defines some utils related with mime type detection

Class Method Summary collapse

Class Method Details

.get_mime_type(v) ⇒ String

Detect a file mime type

Parameters:

  • v (String)

    File path

Returns:

  • (String)

    File mime type



11
12
13
# File 'lib/axlsx/util/mime_type_utils.rb', line 11

def self.get_mime_type(v)
  Marcel::MimeType.for(Pathname.new(v))
end

.get_mime_type_from_uri(v) ⇒ String

Detect a file mime type from URI

Parameters:

  • v (String)

    URI

Returns:

  • (String)

    File mime type



18
19
20
# File 'lib/axlsx/util/mime_type_utils.rb', line 18

def self.get_mime_type_from_uri(v)
  Marcel::MimeType.for(URI.parse(v).open)
end