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.
from nginx