Class DefaultMimeService

java.lang.Object
de.hybris.platform.media.services.impl.DefaultMimeService
All Implemented Interfaces:
MimeService, org.springframework.beans.factory.InitializingBean

public class DefaultMimeService extends Object implements MimeService, org.springframework.beans.factory.InitializingBean
  • Field Details

  • Constructor Details

    • DefaultMimeService

      public DefaultMimeService()
  • Method Details

    • afterPropertiesSet

      public void afterPropertiesSet() throws Exception
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Throws:
      Exception
    • getFileExtensionFromMime

      public String getFileExtensionFromMime(String mime)
      Description copied from interface: MimeService
      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).
      Specified by:
      getFileExtensionFromMime in interface MimeService
      Parameters:
      mime - the mime to check
      Returns:
      the file extension from mime
    • getBestExtensionFromMime

      public String getBestExtensionFromMime(String mime)
      Description copied from interface: MimeService
      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
      Specified by:
      getBestExtensionFromMime in interface MimeService
      Parameters:
      mime - the mime to check
      Returns:
      the best extension from mime
    • getMimeFromFileExtension

      public String getMimeFromFileExtension(String fileName)
      Description copied from interface: MimeService
      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).
      Specified by:
      getMimeFromFileExtension in interface MimeService
      Parameters:
      fileName - the file name to check
      Returns:
      the mime from file extension
    • getConfigParameter

      protected String getConfigParameter(String configKey)
    • getBestMime

      public String getBestMime(String fileName, byte[] firstBytes, String overrideMime)
      Description copied from interface: MimeService
      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.
      Specified by:
      getBestMime in interface MimeService
      Parameters:
      fileName - the file name to check
      firstBytes - the first bytes of data
      overrideMime - the override mime
      Returns:
      the best mime
    • getSupportedMimeTypes

      public Set<String> getSupportedMimeTypes()
      Description copied from interface: MimeService
      Gets set of supported mime types.
      Specified by:
      getSupportedMimeTypes in interface MimeService
      Returns:
      the supported mime types
    • getConfigParametersByPattern

      protected Map<String,String> getConfigParametersByPattern(String keyPrefix)
    • getMimeFromFirstBytes

      public String getMimeFromFirstBytes(byte[] firstBytes)
      Description copied from interface: MimeService
      Gets the mime from first bytes of data or null if it cannot be determined.
      Specified by:
      getMimeFromFirstBytes in interface MimeService
      Parameters:
      firstBytes - the first bytes of data
      Returns:
      the mime from first bytes
    • isZipRelatedMime

      public boolean isZipRelatedMime(String mime)
      Description copied from interface: MimeService
      Checks whether provided mime is zip related mime.
      Specified by:
      isZipRelatedMime in interface MimeService
      Parameters:
      mime - the mime to check
      Returns:
      true, if is zip related mime