Class: S3Direct::HybridStrategy

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

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



38
39
40
# File 'lib/s3direct/content_type_detection.rb', line 38

def filename
  @filename
end

#filetypeObject

Returns the value of attribute filetype

Returns:

  • (Object)

    the current value of filetype



38
39
40
# File 'lib/s3direct/content_type_detection.rb', line 38

def filetype
  @filetype
end

Instance Method Details

#lookupObject



39
40
41
42
43
44
45
46
47
48
49
50
# File 'lib/s3direct/content_type_detection.rb', line 39

def lookup
  types = MIME::Types.type_for(filename)

  type = if types.length == 1
    types.first
  elsif types.length > 1
    media_type = filetype.split('/').first
    types.detect {|t| t.media_type == media_type}
  end

  (type || ContentTypeDetection::Default).content_type
end