Class: S3Direct::ContentTypeDetection

Inherits:
Struct
  • Object
show all
Defined in:
lib/s3direct/content_type_detection.rb

Defined Under Namespace

Classes: Default

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#filenameObject

Returns the value of attribute filename

Returns:

  • (Object)

    the current value of filename



4
5
6
# File 'lib/s3direct/content_type_detection.rb', line 4

def filename
  @filename
end

#filetypeObject

Returns the value of attribute filetype

Returns:

  • (Object)

    the current value of filetype



4
5
6
# File 'lib/s3direct/content_type_detection.rb', line 4

def filetype
  @filetype
end

Instance Method Details

#lookupObject



11
12
13
14
15
16
17
18
19
# File 'lib/s3direct/content_type_detection.rb', line 11

def lookup
  value = if filetype.to_s.empty?
    FilenameStrategy.new(filename).lookup
  else
    HybridStrategy.new(filename, filetype).lookup
  end

  remap(value)
end

#remap(value) ⇒ Object



21
22
23
24
25
26
27
28
# File 'lib/s3direct/content_type_detection.rb', line 21

def remap(value)
  mappings = {
    "application/mp4" => "video/mp4",
    "audio/mp3" => "audio/mpeg"
  }

  mappings.fetch(value, value)
end