Package com.axelor.common
Class MimeTypesUtils
- java.lang.Object
-
- com.axelor.common.MimeTypesUtils
-
public class MimeTypesUtils extends Object
This class defines from static helper methods to deal with Mime Types.
-
-
Constructor Summary
Constructors Constructor Description MimeTypesUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static String
getContentType(File file)
Returns the content type from the file.static String
getContentType(File file, String fileName)
Returns the content type from the file and file name.static String
getContentType(InputStream inputStream, String fileName)
Returns the content type from the file and file name.static String
getContentType(String fileName)
Detects the content type of the given file name.static String
getContentType(Path path)
Returns the content type from the path.static String
getExtensionContentType(String extension)
Returns the content type from the file extension.
-
-
-
Method Detail
-
getContentType
public static String getContentType(File file)
Returns the content type from the file.- Parameters:
file
- the file- Returns:
- detected content type if it is a supported format or "application/octet-stream" if it is an unsupported format
-
getContentType
public static String getContentType(Path path)
Returns the content type from the path.- Parameters:
path
- the path- Returns:
- detected content type if it is a supported format or "application/octet-stream" if it is an unsupported format
-
getContentType
public static String getContentType(String fileName)
Detects the content type of the given file name. The type detection is based on known file name extensions.- Parameters:
fileName
- the file name- Returns:
- detected content type if it is a supported format or "application/octet-stream" if it is an unsupported format
-
getExtensionContentType
public static String getExtensionContentType(String extension)
Returns the content type from the file extension.- Parameters:
extension
- the extension of the file (e.g., "doc")- Returns:
- detected content type if it is a supported format or "application/octet-stream" if it is an unsupported format
-
getContentType
public static String getContentType(File file, String fileName)
Returns the content type from the file and file name.- Parameters:
file
- the file, can benull
fileName
- the file name or extension of the file (e.g., "doc")- Returns:
- detected content type if it is a supported format or "application/octet-stream" if it is an unsupported format
-
getContentType
public static String getContentType(InputStream inputStream, String fileName)
Returns the content type from the file and file name.- Parameters:
inputStream
- the input stream, can benull
fileName
- the file name or extension of the file (e.g., "doc")- Returns:
- detected content type if it is a supported format or "application/octet-stream" if it is an unsupported format
-
-