public static String getMimeType(String filePath) throws Exception
{
if(filePath == null && filePath.equals(""))
{
throws new Exception("filePath is null or empty");
}
Path tmpPath = Paths.get(filePath);
String contentType = Files.probeContentType(tmpPath);
if(contentType == null && contentType.equals(""))
{
contentType = "application/octet-stream";
}
return contentType;
}