Package com.axelor.common
Class MimeTypesUtils
java.lang.Object
com.axelor.common.MimeTypesUtils
This class defines from static helper methods to deal with Mime Types.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringgetContentType(File file) Returns the content type from the file.static StringgetContentType(File file, String fileName) Returns the content type from the file and file name.static StringgetContentType(InputStream inputStream, String fileName) Returns the content type from the file and file name.static StringgetContentType(String fileName) Detects the content type of the given file name.static StringgetContentType(Path path) Returns the content type from the path.static StringgetExtensionContentType(String extension) Returns the content type from the file extension.
-
Constructor Details
-
MimeTypesUtils
public MimeTypesUtils()
-
-
Method Details
-
getContentType
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
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
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
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
Returns the content type from the file and file name.- Parameters:
file- the file, can benullfileName- 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
Returns the content type from the file and file name.- Parameters:
inputStream- the input stream, can benullfileName- 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
-