Get the extension from a MimeType

后端 未结 5 435
不思量自难忘°
不思量自难忘° 2020-12-16 23:27

I want to get the extension from a MimeType.

For example:

video/mp4                       ---->  mp4
application/x         


        
5条回答
  •  甜味超标
    2020-12-16 23:37

    There are two ways generally:

    • have a mapping of MimeTypes to extensions;
    • compute it, using some logic;

    The second approach is really not good, so I offer it only for completion. For the first approach you can use this resource: https://www.freeformatter.com/mime-types-list.html

    I would use HashMap - the key being the MimeType and the value be the extension (or similar).

提交回复
热议问题