Interface MimeService

  • All Known Implementing Classes:
    DefaultMimeService

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

      All Methods Instance Methods Abstract Methods 
      Modifier and Type Method Description
      java.lang.String getBestExtensionFromMime​(java.lang.String mime)
      Gets the best matching extension from mime.
      java.lang.String getBestMime​(java.lang.String fileName, byte[] firstBytes, java.lang.String overrideMime)
      Gets the best mime.
      java.lang.String getFileExtensionFromMime​(java.lang.String mime)
      Gets the file extension from provided mime or null if it cannot be found in configuration properties.
      java.lang.String getMimeFromFileExtension​(java.lang.String fileName)
      Gets the mime from file extension or null if it cannot be found in configuration properties.
      java.lang.String getMimeFromFirstBytes​(byte[] firstBytes)
      Gets the mime from first bytes of data or null if it cannot be determined.
      java.util.Set<java.lang.String> getSupportedMimeTypes()
      Gets set of supported mime types.
      boolean isZipRelatedMime​(java.lang.String mime)
      Checks whether provided mime is zip related mime.
    • Method Detail

      • getFileExtensionFromMime

        java.lang.String getFileExtensionFromMime​(java.lang.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

        java.lang.String getBestExtensionFromMime​(java.lang.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

        java.lang.String getMimeFromFileExtension​(java.lang.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

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

        java.lang.String getBestMime​(java.lang.String fileName,
                                     byte[] firstBytes,
                                     java.lang.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

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

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