A utility to help with mime type detection for a given file path or url.
- Companion:
- object
Value members
Concrete methods
Detects the mime type of a given Byte array.
Detects the mime type of a given Byte array.
When inappropriate MIME Type can not be inferred, "text/pain" is returned.
- Value parameters:
- content
The Byte array for which to detect the mime type
- fallback
A fallback value in case no mime type can be found
Detects the mime type of a given File.
Detects the mime type of a given File.
When inappropriate MIME Type can not be inferred, "application/octet-stream" is returned.
This method guesses the MIME type using java.net.URLConnection.guessContentTypeFromName
.
Therefore, by defining an arbitrary MIME type in the configuration file specified by
the content.types.user.table
property, an arbitrary MIME type can be guessed.
- Value parameters:
- fallback
A fallback value in case no mime type can be found
- file
The File for which to detect the mime type
Detects the mime type of a given InputStream.
Detects the mime type of a given InputStream.
When inappropriate MIME Type can not be inferred, "application/octet-stream" is returned.
- Value parameters:
- fallback
A fallback value in case no mime type can be found
- input
The InputStream for which to detect the mime type
Detects the mime type of a given url.
Detects the mime type of a given url.
When inappropriate MIME Type can not be inferred, "application/octet-stream" is returned.
This method guesses the MIME type using java.net.URLConnection.guessContentTypeFromName
.
Therefore, by defining an arbitrary MIME type in the configuration file specified by
the content.types.user.table
property, an arbitrary MIME type can be guessed.
- Value parameters:
- fallback
A fallback value in case no mime type can be found
- url
The url for which to detect the mime type