Interface MediaTypeDetector


  • public interface MediaTypeDetector
    Detect media type. Minimal implementation checks result based on file suffix.

    If suffix is not sufficient, you can use detectType(String), or implement each of the methods.

    • Method Detail

      • detectType

        default Optional<String> detectType​(String fileString)
        Detect type based on a file string. This may be any string that ends with a file name. Default implementation looks for a suffix (last part of the file string separated by a dot) and if found, invokes the detectExtensionType(String).
        Parameters:
        fileString - path, or name of the file to analyze
        Returns:
        media type if detected
      • detectExtensionType

        Optional<String> detectExtensionType​(String fileSuffix)
        Detect media type from a file suffix.

        Example: If the suffix is txt, this method should return text/plain if this detector cares about text files.

        Parameters:
        fileSuffix - suffix (extension) of a file, without the leading dot
        Returns:
        media type if detected