简体   繁体   中英

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 '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 .

结帐node-mime有一个浏览器版本

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM