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 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.
-
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 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
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
-