- java.lang.Object
-
- io.helidon.common.media.type.MediaTypes
-
public final class MediaTypes extends Object
Media type detection based on a resource.The media type detection uses the following algorithm:
- Queries
MediaTypeDetectorservices in priority order - Checks all
META-INF/media-types.propertiesfiles on classpath for a mapping (suffix=media type) - Checks built-in mapping provided by Helidon (with the usual the web relevant media types)
- Queries
-
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Optional<String>detectExtensionType(String fileSuffix)Detecd media type for a specific file extension.static Optional<String>detectType(String fileName)Detect media type for a path (may be URL, URI, path on a file system).static Optional<String>detectType(URI uri)Detect media type based on URI.static Optional<String>detectType(URL url)Detect media type based on URL.static Optional<String>detectType(Path file)Detect media type for a file on file system.
-
-
-
Method Detail
-
detectType
public static Optional<String> detectType(URL url)
Detect media type based on URL. As there may be an infinite number of urls used in a system, the results are NOT cached.- Parameters:
url- to determine media type for- Returns:
- media type or empty if none found
-
detectType
public static Optional<String> detectType(URI uri)
Detect media type based on URI. Results may not be cached.- Parameters:
uri- to determine media type for- Returns:
- media type or empty if none found
-
detectType
public static Optional<String> detectType(Path file)
Detect media type for a file on file system. Results may not be cached.- Parameters:
file- file on a file system- Returns:
- media type or empty if none found
-
detectType
public static Optional<String> detectType(String fileName)
Detect media type for a path (may be URL, URI, path on a file system). Results may not be cached. If you haveURL,URI, orPathplease use the other methods on this class.- Parameters:
fileName- any string that has a file name as its last element- Returns:
- media type or empty if none found
- See Also:
detectType(java.net.URI),detectType(java.net.URL),detectType(java.nio.file.Path)
-
detectExtensionType
public static Optional<String> detectExtensionType(String fileSuffix)
Detecd media type for a specific file extension. Results are cached.- Parameters:
fileSuffix- suffix of a file, such astxt,properties, orjpeg. Without the leading dot.- Returns:
- media type for the file suffix or empty if none found
-
-