开发者

Is there a helper function to find a mime type corresponding to an extension

开发者 https://www.devze.com 2023-02-18 02:35 出处:网络
Mime types corresponding to an extension is available over here. We currently have the following code to translate this for the most commonly used extension types.

Mime types corresponding to an extension is available over here. We currently have the following code to translate this for the most commonly used extension types.

     String getContentType(String extension) {
        if (extens开发者_运维问答ion.equals("png") || extension.equals("gif")
                || extension.equals("ico") || extension.equals("tiff")) {
            contentType = "image/" + extension;
        } else if (extension.equals("jpg") || extension.equals("jpeg")) {
            contentType = "image/jpeg";
        } 
        ........
     }

But is there a function in a open source library which provides this complete mapping?

0

精彩评论

暂无评论...
验证码 换一张
取 消