Class: MIME::Types

Inherits:
Object
  • Object
show all
Defined in:
lib/rcs-common/mime.rb

Instance Method Summary collapse

Instance Method Details

#mime_type_forObject

rename the original method to be used in our wrapper



12
# File 'lib/rcs-common/mime.rb', line 12

alias mime_type_for type_for

#type_for(filename, platform = false) ⇒ Object

our wrapper which adds our types



15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/rcs-common/mime.rb', line 15

def type_for(filename, platform = false)
  # call the original method
  type = mime_type_for(filename, platform)
  
  if type.empty? then
    case File.extname(filename)
      when '.cod'
        type = MIME::Type.from_array('application/vnd.rim.cod', 'cod', '8bit', 'linux')
      when '.apk'
        type = MIME::Type.from_array('application/vnd.android.package-archive', 'apk', '8bit', 'linux')
      when '.aetx'
        type = MIME::Type.from_array('application/x-aetx', 'aetx', '8bit', 'linux')
      when '.xap'
        type = MIME::Type.from_array('application/x-silverlight-app', 'xap', '8bit', 'linux')
    end
  end
  return type
end