If I have a content-type, how can I get its default file extension?
For example, given one of these content-types, I should get the following file extensions:
+------------------------+----------------+
| Content-Type | File Extension |
+------------------------+----------------+
| text/plain | .txt |
| application/javascript | .js |
| application/gzip | .gz |
+------------------------+----------------+
If there is no way to get these extensions automatically in JavaScript, my next solution would be to create a simple relationship between content-type and file extension in a JavaScript array. Therefore, I would accept an answer which has a simple table/database of the most common content-type and file extensions.
For detecting MIME-types, use the aptly named "mimetype" command. It has a number of options for formatting the output, it even has an option for backward compatibility to "file". But most of all, it accepts input not only as file, but also via stdin/pipe, so you can avoid temporary files when processing streams.
TypeScript is another file format that uses the . TS file extension. These are text files used to make JavaScript applications and are in fact similar to JavaScript (.
Extension Default means the occurrence of any Event of Default or any event that with the giving of notice or the lapse of time could become an Event of Default other than the failure to pay the principal balance of the Bridge Loans or the Conversion Notes on the Initial Maturity Date.
For Node applications, there is a more up-to-date answer now, which is to use the mime-types NPM package, e.g.:
var mime = require('mime-types'),
fileExtension = mime.extension('text/plain');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With