Sha256: 1efb6775f680457b9a802f55773d9a757f723a5c39938eaf2a7da42b8783d3a9

Contents?: true

Size: 333 Bytes

Versions: 15

Compression:

Stored size: 333 Bytes

Contents

module Hydra::PCDM
  module GetMimeTypeForFile
    def self.call(path)
      raise 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

15 entries across 15 versions & 1 rubygems

Version Path
hydra-pcdm-1.4.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-1.3.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-1.2.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-1.1.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-1.0.1 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-1.0.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.11.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.10.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.9.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.8.2 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.8.1 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.8.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.8.0.beta1 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.7.0 lib/hydra/pcdm/services/file/get_mime_type.rb
hydra-pcdm-0.6.0 lib/hydra/pcdm/services/file/get_mime_type.rb