Class IdentifyMimeType
java.lang.Object
org.apache.nifi.components.AbstractConfigurableComponent
org.apache.nifi.processor.AbstractSessionFactoryProcessor
org.apache.nifi.processor.AbstractProcessor
org.apache.nifi.processors.standard.IdentifyMimeType
- All Implemented Interfaces:
org.apache.nifi.components.ConfigurableComponent,org.apache.nifi.processor.Processor
@SideEffectFree
@SupportsBatching
@InputRequirement(INPUT_REQUIRED)
@Tags({"compression","gzip","bzip2","zip","MIME","mime.type","file","identify"})
@CapabilityDescription("Attempts to identify the MIME Type used for a FlowFile. If the MIME Type can be identified, an attribute with the name \'mime.type\' is added with the value being the MIME Type. If the MIME Type cannot be determined, the value will be set to \'application/octet-stream\'. In addition, the attribute \'mime.extension\' will be set if a common file extension for the MIME Type is known. If the MIME Type detected is of type text/*, attempts to identify the charset used and an attribute with the name \'mime.charset\' is added with the value being the charset.")
@WritesAttribute(attribute="mime.type",description="This Processor sets the FlowFile\'s mime.type attribute to the detected MIME Type. If unable to detect the MIME Type, the attribute\'s value will be set to application/octet-stream") @WritesAttribute(attribute="mime.extension",description="This Processor sets the FlowFile\'s mime.extension attribute to the file extension associated with the detected MIME Type. If there is no correlated extension, the attribute\'s value will be empty") @WritesAttribute(attribute="mime.charset",description="This Processor sets the FlowFile\'s mime.charset attribute to the detected charset. If unable to detect the charset or the detected MIME type is not of type text/*, the attribute will not be set")
public class IdentifyMimeType
extends org.apache.nifi.processor.AbstractProcessor
Attempts to detect the MIME Type of a FlowFile by examining its contents. If the MIME Type is determined, it is added
to an attribute with the name mime.type. In addition, mime.extension is set if a common file extension is known.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final org.apache.tika.config.TikaConfigstatic final org.apache.nifi.components.PropertyDescriptorstatic final org.apache.nifi.components.PropertyDescriptorprivate static final Stringprivate static final Stringprivate org.apache.tika.detect.Detectorprivate org.apache.tika.detect.EncodingDetector(package private) static final org.apache.nifi.components.AllowableValueprivate org.apache.tika.mime.MimeTypes(package private) static final org.apache.nifi.components.AllowableValueprivate static final List<org.apache.nifi.components.PropertyDescriptor> static final org.apache.nifi.processor.Relationshipprivate static final Set<org.apache.nifi.processor.Relationship> (package private) static final org.apache.nifi.components.AllowableValuestatic final org.apache.nifi.components.PropertyDescriptor -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate org.apache.tika.mime.MimeTypescreateCustomMimeTypes(String configStrategy, org.apache.nifi.context.PropertyContext context) protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) Set<org.apache.nifi.processor.Relationship> protected List<org.apache.nifi.components.PropertyDescriptor> private CharsetidentifyCharset(org.apache.tika.io.TikaInputStream tikaStream, org.apache.tika.metadata.Metadata metadata, org.apache.tika.mime.MediaType mediaType) private StringlookupExtension(String mediaTypeString, org.apache.nifi.logging.ComponentLog logger) voidvoidonTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) voidsetup(org.apache.nifi.processor.ProcessContext context) Methods inherited from class org.apache.nifi.processor.AbstractProcessor
onTriggerMethods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor
getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueMethods inherited from class org.apache.nifi.components.AbstractConfigurableComponent
equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface org.apache.nifi.components.ConfigurableComponent
getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validateMethods inherited from interface org.apache.nifi.processor.Processor
isStateful, migrateRelationships
-
Field Details
-
PRESET
static final org.apache.nifi.components.AllowableValue PRESET -
REPLACE
static final org.apache.nifi.components.AllowableValue REPLACE -
MERGE
static final org.apache.nifi.components.AllowableValue MERGE -
USE_FILENAME_IN_DETECTION
public static final org.apache.nifi.components.PropertyDescriptor USE_FILENAME_IN_DETECTION -
CONFIG_STRATEGY
public static final org.apache.nifi.components.PropertyDescriptor CONFIG_STRATEGY -
CUSTOM_MIME_CONFIGURATION
public static final org.apache.nifi.components.PropertyDescriptor CUSTOM_MIME_CONFIGURATION -
PROPERTY_DESCRIPTORS
-
REL_SUCCESS
public static final org.apache.nifi.processor.Relationship REL_SUCCESS -
RELATIONSHIPS
-
CUSTOM_MIME_TYPES_FILENAME
- See Also:
-
DEFAULT_MIME_TYPES_PATH
- See Also:
-
config
private final org.apache.tika.config.TikaConfig config -
detector
private org.apache.tika.detect.Detector detector -
encodingDetector
private org.apache.tika.detect.EncodingDetector encodingDetector -
mimeTypes
private org.apache.tika.mime.MimeTypes mimeTypes
-
-
Constructor Details
-
IdentifyMimeType
public IdentifyMimeType()
-
-
Method Details
-
migrateProperties
-
setup
- Throws:
IOException
-
getRelationships
- Specified by:
getRelationshipsin interfaceorg.apache.nifi.processor.Processor- Overrides:
getRelationshipsin classorg.apache.nifi.processor.AbstractSessionFactoryProcessor
-
getSupportedPropertyDescriptors
- Overrides:
getSupportedPropertyDescriptorsin classorg.apache.nifi.components.AbstractConfigurableComponent
-
onTrigger
public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session) - Specified by:
onTriggerin classorg.apache.nifi.processor.AbstractProcessor
-
lookupExtension
-
identifyCharset
private Charset identifyCharset(org.apache.tika.io.TikaInputStream tikaStream, org.apache.tika.metadata.Metadata metadata, org.apache.tika.mime.MediaType mediaType) throws IOException - Throws:
IOException
-
customValidate
protected Collection<org.apache.nifi.components.ValidationResult> customValidate(org.apache.nifi.components.ValidationContext validationContext) - Overrides:
customValidatein classorg.apache.nifi.components.AbstractConfigurableComponent
-
createCustomMimeTypes
private org.apache.tika.mime.MimeTypes createCustomMimeTypes(String configStrategy, org.apache.nifi.context.PropertyContext context) throws org.apache.tika.mime.MimeTypeException, IOException - Throws:
org.apache.tika.mime.MimeTypeExceptionIOException
-