RingoJS

Module ringo/mime

This module provides functionality for determining the MIME type for a given file extension.

Example

>> const mime = require('ringo/mime');
>> mime.mimeType('photo.jpg');
'image/jpeg'
>> mime.mimeType('video.m4v');
'video/mp4'
>> mime.mimeType('feed.rss');
'application/rss+xml'

Functions

Properties


MIME_TYPES

A list of common MIME types, keyed by file extension.


mimeType (fileName, fallback)

Determines the MIME type for the given file extension. If the file extension is unknown, the fallback argument is returned. If that is undefined, the function returns "application/octet-stream".

Parameters

String fileName

a file name

String fallback

MIME type to return if file extension is unknown

Returns

String

the MIME type for the file name