Interface MimeService
- All Known Implementing Classes:
DefaultMimeService
public interface MimeService
Interface provides method for manipulating mime types in the hybris platform.
-
Method Summary
Modifier and TypeMethodDescriptionGets the best matching extension from mime.getBestMime(String fileName, byte[] firstBytes, String overrideMime) Gets the best mime.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.
-
Method Details
-
getFileExtensionFromMime
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
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
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
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
Gets 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.- Parameters:
fileName- the file name to checkfirstBytes- the first bytes of dataoverrideMime- the override mime- Returns:
- the best mime
-
getSupportedMimeTypes
Gets set of supported mime types.- Returns:
- the supported mime types
-
isZipRelatedMime
Checks whether provided mime is zip related mime.- Parameters:
mime- the mime to check- Returns:
- true, if is zip related mime
-