public interface MimetypeRegistry
Flexible registry of mimetypes.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_MIMETYPE |
Modifier and Type | Method and Description |
---|---|
List<String> |
getExtensionsFromMimetypeName(String mimetypeName)
Returns the extension for given mimetype.
|
MimetypeEntry |
getMimetypeEntryByMimeType(String mimetype)
Gets a mimetype entry given the normalized mimetype.
|
MimetypeEntry |
getMimetypeEntryByName(String name)
Gets a mimetype entry by name.
|
String |
getMimetypeFromBlob(Blob blob)
Returns the mime type from a given stream.
|
String |
getMimetypeFromBlobWithDefault(Blob blob,
String defaultMimetype)
Returns the mime type from a given blob or provided default if not possible.
|
String |
getMimetypeFromExtension(String extension)
Returns the mime type from a given extension.
|
String |
getMimetypeFromFile(File file)
Returns the mime type given a file.
|
String |
getMimetypeFromFilename(String filename)
Returns the mime type from a given filename.
|
String |
getMimetypeFromFilenameAndBlobWithDefault(String filename,
Blob blob,
String defaultMimetype)
Finds the mimetype of some content according to its filename and / or binary content.
|
String |
getMimetypeFromStream(InputStream stream)
Returns the mime type from a given stream.
|
String |
getMimetypeFromStreamWithDefault(InputStream is,
String defaultMimetype)
Returns the mime type from a given stream or provided default if not possible.
|
Blob |
updateMimetype(Blob blob)
Update the mimetype field of a Blob based on the embedded filename with fallback to binary sniffing.
|
Blob |
updateMimetype(Blob blob,
String filename)
Update the mimetype field of a Blob based on the provided filename with fallback to binary sniffing.
|
static final String DEFAULT_MIMETYPE
String getMimetypeFromStream(InputStream stream) throws MimetypeNotFoundException, MimetypeDetectionException
MimetypeNotFoundException
- if mimetype sniffing failed to identify a registered mime typeMimetypeDetectionException
- if unexpected problem prevent the detection to work as expectedString getMimetypeFromBlob(Blob blob) throws MimetypeNotFoundException, MimetypeDetectionException
MimetypeNotFoundException
- if mimetype sniffing failed to identify a registered mime typeMimetypeDetectionException
- if unexpected problem prevent the detection to work as expectedString getMimetypeFromBlobWithDefault(Blob blob, String defaultMimetype) throws MimetypeDetectionException
MimetypeDetectionException
String getMimetypeFromStreamWithDefault(InputStream is, String defaultMimetype) throws MimetypeDetectionException
MimetypeDetectionException
String getMimetypeFromFilename(String filename)
String getMimetypeFromFile(File file) throws MimetypeNotFoundException, MimetypeDetectionException
MimetypeNotFoundException
- if mimetype sniffing failedMimetypeDetectionException
- if unexpected problem prevent the detection to work as expectedList<String> getExtensionsFromMimetypeName(String mimetypeName)
mimetypeName
- the mimetype name.MimetypeEntry getMimetypeEntryByName(String name)
name
- the mimetype name.MimetypeEntry getMimetypeEntryByMimeType(String mimetype)
mimetype
- the normalized mimetypeString getMimetypeFromFilenameAndBlobWithDefault(String filename, Blob blob, String defaultMimetype) throws MimetypeDetectionException
filename
- extension to analyzeblob
- content to be analyzed if filename is ambiguousdefaultMimetype
- defaultMimeType to be used if no foundMimetypeDetectionException
Blob updateMimetype(Blob blob, String filename) throws MimetypeDetectionException
blob
- content to be analyzed if filename is ambiguousfilename
- with extension to analyzeMimetypeDetectionException
Blob updateMimetype(Blob blob) throws MimetypeDetectionException
blob
- content to be analyzed if filename is ambiguousMimetypeDetectionException
String getMimetypeFromExtension(String extension) throws MimetypeNotFoundException
MimetypeNotFoundException
Copyright © 2015 Nuxeo SA. All rights reserved.