DEV Community

Rocktim Saikia
Rocktim Saikia

Posted on • Updated on

Get the availabe MIME types of a given extension.

I just recently published a simple node module that returns the availabe starndard MIME types of a given an extension.

Installation

npm install mime-type-check
Enter fullscreen mode Exit fullscreen mode

Usage

const getMimeType = require('mime-type-check');

getMimeType('svg'); //=> ['image/svg+xml']
getMimeType('png'); //=> ['image/png']
getMimeType('3gpp') //=> ['audio/3gpp', 'video/3gpp']
Enter fullscreen mode Exit fullscreen mode

GitHub logo rocktimsaikia / mime-type-check

Check all the available MIME types of an extension

mime-type-check build license

Check all the available MIME types of a extension.

It uses Mime-db as its core database.
Do not use this module to actually check the MIME type of a local or remote file. For that use File-type

Install

npm install mime-type-check
Enter fullscreen mode Exit fullscreen mode

Usage

const getMimeType = require("mime-type-check");

getMimeType("svg"); //=> ['image/svg+xml']
getMimeType("png"); //=> ['image/png']
getMimeType("3gpp"); //=> ['audio/3gpp', 'video/3gpp']
Enter fullscreen mode Exit fullscreen mode

API

getMimeType(string)

string is the extension to check the mimetypes for.

License

MIT © Rocktim Saikia




[PS: I created this module to use it in another project that I am currently workin on. Thought someone might find it helpful so made a quick post.]

Top comments (0)