Interface MimeService

All Known Implementing Classes:
DefaultMimeService

public interface MimeService
Interface provides method for manipulating mime types in the hybris platform.
  • Method Details

    • getFileExtensionFromMime

      String getFileExtensionFromMime(String mime)
      Gets the file extension from provided mime or null if it cannot be found in configuration properties. List of all configured mime types and corresponding file extensions can be found in advanced.properties file (look for keys starting from media.customextension).
      Parameters:
      mime - the mime to check
      Returns:
      the file extension from mime
    • getBestExtensionFromMime

      String getBestExtensionFromMime(String mime)
      Gets the best matching extension from mime. This method first tries to look into configured file extensions in advanced.properties file and if cannot be found default bin file extension is returned
      Parameters:
      mime - the mime to check
      Returns:
      the best extension from mime
    • getMimeFromFileExtension

      String getMimeFromFileExtension(String fileName)
      Gets the mime from file extension or null if it cannot be found in configuration properties. List of all configured mime types and corresponding file extensions can be found in advanced.properties file (look for keys starting from mediatype.by.fileextension).
      Parameters:
      fileName - the file name to check
      Returns:
      the mime from file extension
    • getMimeFromFirstBytes

      String getMimeFromFirstBytes(byte[] firstBytes)
      Gets the mime from first bytes of data or null if it cannot be determined.
      Parameters:
      firstBytes - the first bytes of data
      Returns:
      the mime from first bytes
    • getBestMime

      String getBestMime(String fileName, byte[] firstBytes, String overrideMime)
      Gets the best mime. This method first tries to determine from fileName extension. If it cannot be determined provided firstBytes of data are used to dermine mime. If it fail then overrideMime may be used if it is on list of supported mime types (look for media.customextension keys in advanced.properties file for supported mime types and file extensions). Finally if it fail than default mime is returned which is always application/octet-stream.
      Parameters:
      fileName - the file name to check
      firstBytes - the first bytes of data
      overrideMime - the override mime
      Returns:
      the best mime
    • getSupportedMimeTypes

      Set<String> getSupportedMimeTypes()
      Gets set of supported mime types.
      Returns:
      the supported mime types
    • isZipRelatedMime

      boolean isZipRelatedMime(String mime)
      Checks whether provided mime is zip related mime.
      Parameters:
      mime - the mime to check
      Returns:
      true, if is zip related mime