Skip to content

infinity.mimeType

Provides functionality for matching MIME-Types to file extensions and vice versa. The MIME-Types have to be configured inside the [MimeTypes] block of the infinity.ini file inside the folder of the used infinity executable file (refer to infinity.default.ini for a set of default mappings).

Module: infinity.mimeType

infinity.loadModule('infinity.mimeType');

let mimeType = infinity.mimeType.getMimeType('.jpg');
console.debug(mimeType);
//image/jpeg


let extension = infinity.mimeType.getExtension('text/javascript');
console.debug(extension);
//.js

Functions

getExtension()

Returns the matching file extension for the given MIME-Type.

Signature:

getExtension( mimeType: string ): string

Parameters:

  • mimeType: string

    The MIME-Type to be matched to a file extension.

Return type: string

Example:

infinity.loadModule('infinity.mimeType');

let mimeType = infinity.mimeType.getMimeType('.jpg');
console.debug(mimeType);
//application/octet-stream

getMimeType()

Returns the matching MIME-Type for the given file extension.

Signature:

getMimeType( extension: string ): string

Parameters:

  • extension: string

    The file extension to be matched to a MIME-Type.

Return type: string

Example:

infinity.loadModule('infinity.mimeType');

let extension = infinity.mimeType.getExtension('text/javascript');
console.debug(extension);
//.js