@@ -3490,4 +3490,69 @@ public static String Sanitize(String input, HashMap<Character, Character> whiteL
34903490 }
34913491 return sanitizedInput .toString ();
34923492 }
3493+
3494+
3495+ public static boolean isKnownContentType (String type )
3496+ {
3497+ if (type != null )
3498+ {
3499+ for (int i = 0 ; i < contentTypes .length ; i ++)
3500+ {
3501+ if (contentTypes [i ].length >= 2 )
3502+ {
3503+ if (type .equalsIgnoreCase (contentTypes [i ][1 ]))
3504+ return true ;
3505+ }
3506+ }
3507+ }
3508+ return false ;
3509+ }
3510+
3511+ public static String getContentFromExt ( String extension )
3512+ {
3513+ if (extension != null )
3514+ {
3515+ extension = extension .toLowerCase ();
3516+ for (int i = 0 ; i < contentTypes .length ; i ++) {
3517+ if (contentTypes [i ][0 ].equals (extension .trim ()))
3518+ return contentTypes [i ][1 ];
3519+ }
3520+ }
3521+ return null ;
3522+ }
3523+
3524+ private static final String contentTypes [][] = {
3525+ {"txt" , "text/plain" },
3526+ {"rtx" , "text/richtext" },
3527+ {"htm" , "text/html" },
3528+ {"html" , "text/html" },
3529+ {"xml" , "text/xml" },
3530+ {"aif" , "audio/x-aiff" },
3531+ {"au" , "audio/basic" },
3532+ {"wav" , "audio/wav" },
3533+ {"bmp" , "image/bmp" },
3534+ {"gif" , "image/gif" },
3535+ {"jpe" , "image/jpeg" },
3536+ {"jpeg" , "image/jpeg" },
3537+ {"jpg" , "image/jpeg" },
3538+ {"jfif" , "image/pjpeg" },
3539+ {"tif" , "image/tiff" },
3540+ {"tiff" , "image/tiff" },
3541+ {"png" , "image/x-png" },
3542+ {"3gp" , "video/3gpp" },
3543+ {"3g2" , "video/3gpp2" },
3544+ {"mpg" , "video/mpeg" },
3545+ {"mpeg" , "video/mpeg" },
3546+ {"mov" , "video/quicktime" },
3547+ {"qt" , "video/quicktime" },
3548+ {"avi" , "video/x-msvideo" },
3549+ {"exe" , "application/octet-stream" },
3550+ {"dll" , "application/x-msdownload" },
3551+ {"ps" , "application/postscript" },
3552+ {"pdf" , "application/pdf" },
3553+ {"svg" , "image/svg+xml" },
3554+ {"tgz" , "application/x-compressed" },
3555+ {"zip" , "application/x-zip-compressed" },
3556+ {"gz" , "application/x-gzip" }
3557+ };
34933558}
0 commit comments