A MIME type sniffer for Go.
MIMESniffer implements the algorithm described at
here and uses the file signatures (aka
magic numbers)
listed here to determine
the MIME type of the given data. So it can be used as an alternative for the
http.DetectContentType.
- Extremely easy to use
- Two functions
- Quite fast
- Supports a wide range of MIME types
application/epub+zipapplication/font-sfntapplication/font-woffapplication/mswordapplication/octet-streamapplication/oggapplication/pdfapplication/postscriptapplication/rtfapplication/vnd.ms-cab-compressedapplication/vnd.ms-excelapplication/vnd.ms-fontobjectapplication/vnd.ms-powerpointapplication/vnd.openxmlformats-officedocument.presentationml.presentationapplication/vnd.openxmlformats-officedocument.spreadsheetml.sheetapplication/vnd.openxmlformats-officedocument.wordprocessingml.documentapplication/wasmapplication/x-7z-compressedapplication/x-bzip2application/x-compressapplication/x-debapplication/x-executableapplication/x-google-chrome-extensionapplication/x-gzipapplication/x-lzipapplication/x-msdownloadapplication/x-nintendo-nes-romapplication/x-rar-compressedapplication/x-rpmapplication/x-shockwave-flashapplication/x-sqlite3application/x-tarapplication/x-unix-archiveapplication/x-xzapplication/zipaudio/aacaudio/aiffaudio/amraudio/basicaudio/m4aaudio/midiaudio/mpegaudio/oggaudio/waveaudio/x-flacaudio/x-wavfont/collectionfont/otffont/ttffont/woff2font/woffimage/bmpimage/gifimage/jp2image/jpegimage/pngimage/tiffimage/vnd.adobe.photoshopimage/vnd.microsoft.iconimage/webpimage/x-canon-cr2text/html; charset=utf-8text/plain; charset=utf-16betext/plain; charset=utf-16letext/plain; charset=utf-8text/xml; charset=utf-8video/avivideo/mp4video/mpegvideo/quicktimevideo/webmvideo/x-flvvideo/x-m4vvideo/x-matroskavideo/x-ms-wmvvideo/x-msvideo
- Zero third-party dependencies
Open your terminal and execute
$ go get github.com/aofei/mimesnifferdone.
The only requirement is the Go, at least v1.13.
If you want to discuss MIMESniffer, or ask questions about it, simply post questions or ideas here.
If you want to help build MIMESniffer, simply follow this to send pull requests here.
This project is licensed under the MIT License.
License can be found here.