Sha256: 8104a5b463307916f534147e53db21cbc780d19acbbf0a899d3dfbf611730877

Contents?: true

Size: 548 Bytes

Versions: 5

Compression:

Stored size: 548 Bytes

Contents

# frozen_string_literal: true

require 'open-uri'

module Axlsx
  # This module defines some utils related with mime type detection
  module MimeTypeUtils
    # Detect a file mime type
    # @param [String] v File path
    # @return [String] File mime type
    def self.get_mime_type(v)
      Marcel::MimeType.for(Pathname.new(v))
    end

    # Detect a file mime type from URI
    # @param [String] v URI
    # @return [String] File mime type
    def self.get_mime_type_from_uri(v)
      Marcel::MimeType.for(URI.parse(v).open)
    end
  end
end

Version data entries

5 entries across 5 versions & 2 rubygems

Version Path
cm-admin-1.5.22 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/util/mime_type_utils.rb
cm-admin-1.5.21 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/util/mime_type_utils.rb
cm-admin-1.5.20 vendor/bundle/ruby/3.3.0/gems/caxlsx-4.1.0/lib/axlsx/util/mime_type_utils.rb
caxlsx-4.1.0 lib/axlsx/util/mime_type_utils.rb
caxlsx-4.0.0 lib/axlsx/util/mime_type_utils.rb