Is there a client side JavaScript mimetype library?
I'm looking for a client side JavaScript mimetype library similar to Python's mimetypes, or the '开发者_StackOverflow社区mime' Node module.
I have two related use cases in mind. First is for validating the mimetype in an <input type="file"/>
element. The second is for validating a bunch of filenames that come reading the file entries of a ZIP file via js-unzip and Cheeso's unzip utility.
For the first target you can use list of mime types by extention convert in to JSON compress with gz and then use with your script. It's the most simplest way to do this crossbrowser.
The second you can use bash-comands in node, untar archive to tmp and then get mime types of the each file. Parse result with js and check if it compares with you validation list
checkout node-mime thay have a browser version
精彩评论