I need a quick estimate if file is binary/text looking just at its extension, errors are acceptable.
Example: all images, audio, video are considered binary (i.e. .jpg
, .gif
, .mp4
, etc.).
Are there any more or less complete lists I could use for this purpose? I also checked https://golang.org/pkg/mime/#TypeByExtension but it does not seem to be a good fit.
Thanks!
Decided to go with http://www.file-extensions.org/filetype/extension/name/bitmap-image-files scrapping...
Just inject jQuery and execute something like:
var rAN = new RegExp("^[a-zA-Z0-9]+$");
var extList = $('.color3').map(function(){
return $(this).html();
}).get().filter(function(e){
return rAN.test(e);
})
JSON.stringify(extList);
which should give a JSON representation of currently listed extensions =)
That package seems exactly what you want. How is it not a good fit?
Basically, if the MIME type does not include "text" then it's binary.
From what I understand you are looking for a MIME type list. There is this great resource here that gives a large list of each type and their content.
It looks like the mime package is a perfect fit for this use case.