Sha256: 264a65f0cf4bf8724602c3cf58ae1e4e71e98a257967ca247adf68999636d4bf

Contents?: true

Size: 331 Bytes

Versions: 4

Compression:

Stored size: 331 Bytes

Contents

module Hydra::PCDM
  class GetMimeTypeForFile
    def self.call(path)
      fail ArgumentError, 'supplied argument should be a path to a file' unless path.is_a?(String)
      mime_types = ::MIME::Types.of(::File.basename(path))
      mime_types.empty? ? 'application/octet-stream' : mime_types.first.content_type
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hydra-pcdm-0.3.2 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.3.1 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.3.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.2.0 lib/hydra/pcdm/services/file/get_mime_type.rb