public interface MimetypeRegistry
Flexible registry of mimetypes.
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_MIMETYPE |
static String |
PDF_EXTENSION |
static String |
PDF_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)
Finds the mimetype of a Blob content and returns 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 |
getMimetypeFromFilenameWithBlobMimetypeFallback(String filename,
Blob blob,
String defaultMimetype)
Finds the mimetype of some content according to its filename or binary mime type or binary content.
|
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.
|
Blob |
updateMimetype(Blob blob,
String filename,
Boolean withBlobMimetypeFallback)
Update the mimetype field of a Blob based on the provided filename with fallback to binary.
|
static final String DEFAULT_MIMETYPE
static final String PDF_MIMETYPE
static final String PDF_EXTENSION
String 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
blob
- content to be analyzeddefaultMimetype
- defaultMimeType to be used if no foundMimetypeDetectionException
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
String getMimetypeFromFilenameWithBlobMimetypeFallback(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, Boolean withBlobMimetypeFallback) throws MimetypeDetectionException
blob
- content to be analyzed if filename is ambiguousfilename
- with extension to analyzewithBlobMimetypeFallback
- to consider blob mimetype as fallback or notMimetypeDetectionException
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 © 2017 Nuxeo. All rights reserved.