detect-content-type implements the algorithm described at http://mimesniff.spec.whatwg.org/ to determine the Content-Type of the given data. It considers at most the first 512 bytes of data. It always returns a valid MIME type: if it cannot determine a mo
npm install detect-content-typeThis module is useful in cases where it is not possible to determine the Content-Type of the data using filename extension, either because file does not have an extension or the filename is not available.
```
npm install detect-content-type
or
``
yarn add detect-content-type
javascript
import detectContentType from 'detect-content-type'
`Using CommonJS:
`javascript
var detectContentType = require('detect-content-type')
`Usage
detectContentType takes a Buffer, and determines its Content-Type. It considers at most
512 bytes of data. detectContentType always returns a valid MIME type. If it cannot determine a
more specific one, it returns application/octet-stream.
`javascript
let ct = detectContentType(Buffer.from("")) // returns 'text/html; charset=utf-8'
``[DetectContentType]: https://golang.org/pkg/net/http/#DetectContentType