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 Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidGets the best matching extension from mime.getBestMime(String fileName, byte[] firstBytes, String overrideMime) Gets the best mime.protected StringgetConfigParameter(String configKey) getConfigParametersByPattern(String keyPrefix) Gets the file extension from provided mime or null if it cannot be found in configuration properties.getMimeFromFileExtension(String fileName) Gets the mime from file extension or null if it cannot be found in configuration properties.getMimeFromFirstBytes(byte[] firstBytes) Gets the mime from first bytes of data or null if it cannot be determined.Gets set of supported mime types.booleanisZipRelatedMime(String mime) Checks whether provided mime is zip related mime.
-
Field Details
-
FALLBACK_FILE_EXT
- See Also:
-
FALLBACK_MIME
- See Also:
-
ZIP_MIME
- See Also:
-
X_ZIP_MIME
- See Also:
-
X_ZIP_COMPRESSED_MIME
- See Also:
-
CUSTOM_EXTENSION_PREFIX
- See Also:
-
CUSTOM_MIMETYPE_PREFIX
- See Also:
-
-
Constructor Details
-
DefaultMimeService
public DefaultMimeService()
-
-
Method Details
-
afterPropertiesSet
- Specified by:
afterPropertiesSetin interfaceorg.springframework.beans.factory.InitializingBean- Throws:
Exception
-
getFileExtensionFromMime
Description copied from interface:MimeServiceGets 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:
getFileExtensionFromMimein interfaceMimeService- Parameters:
mime- the mime to check- Returns:
- the file extension from mime
-
getBestExtensionFromMime
Description copied from interface:MimeServiceGets 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:
getBestExtensionFromMimein interfaceMimeService- Parameters:
mime- the mime to check- Returns:
- the best extension from mime
-
getMimeFromFileExtension
Description copied from interface:MimeServiceGets 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:
getMimeFromFileExtensionin interfaceMimeService- Parameters:
fileName- the file name to check- Returns:
- the mime from file extension
-
getConfigParameter
-
getBestMime
Description copied from interface:MimeServiceGets the best mime. This method first tries to determine fromfileNameextension. If it cannot be determined providedfirstBytesof data are used to dermine mime. If it fail thenoverrideMimemay 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:
getBestMimein interfaceMimeService- Parameters:
fileName- the file name to checkfirstBytes- the first bytes of dataoverrideMime- the override mime- Returns:
- the best mime
-
getSupportedMimeTypes
Description copied from interface:MimeServiceGets set of supported mime types.- Specified by:
getSupportedMimeTypesin interfaceMimeService- Returns:
- the supported mime types
-
getConfigParametersByPattern
-
getMimeFromFirstBytes
Description copied from interface:MimeServiceGets the mime from first bytes of data or null if it cannot be determined.- Specified by:
getMimeFromFirstBytesin interfaceMimeService- Parameters:
firstBytes- the first bytes of data- Returns:
- the mime from first bytes
-
isZipRelatedMime
Description copied from interface:MimeServiceChecks whether provided mime is zip related mime.- Specified by:
isZipRelatedMimein interfaceMimeService- Parameters:
mime- the mime to check- Returns:
- true, if is zip related mime
-