@EventDriven @SideEffectFree @SupportsBatching @InputRequirement(value=INPUT_REQUIRED) @Tags(value={"compression","gzip","bzip2","zip","MIME","mime.type","file","identify"}) @CapabilityDescription(value="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 both Config File and Config Body are not set, the default NiFi MIME Types will be used.") @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") public class IdentifyMimeType extends 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.
MIME Type detection is performed by Apache Tika; more information about detection is available at http://tika.apache.org.
| Modifier and Type | Field and Description |
|---|---|
private org.apache.tika.config.TikaConfig |
config |
private org.apache.tika.detect.Detector |
detector |
static PropertyDescriptor |
MIME_CONFIG_BODY |
static PropertyDescriptor |
MIME_CONFIG_FILE |
private org.apache.tika.mime.MimeTypes |
mimeTypes |
private List<PropertyDescriptor> |
properties |
static Relationship |
REL_SUCCESS |
private Set<Relationship> |
relationships |
static PropertyDescriptor |
USE_FILENAME_IN_DETECTION |
| Constructor and Description |
|---|
IdentifyMimeType() |
| Modifier and Type | Method and Description |
|---|---|
protected Collection<ValidationResult> |
customValidate(ValidationContext validationContext) |
Set<Relationship> |
getRelationships() |
protected List<PropertyDescriptor> |
getSupportedPropertyDescriptors() |
protected void |
init(ProcessorInitializationContext context) |
void |
onTrigger(ProcessContext context,
ProcessSession session) |
void |
setup(ProcessContext context) |
onTriggergetControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrueequals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validateclone, finalize, getClass, notify, notifyAll, wait, wait, waitisStatefulgetPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validatepublic static final PropertyDescriptor USE_FILENAME_IN_DETECTION
public static final PropertyDescriptor MIME_CONFIG_FILE
public static final PropertyDescriptor MIME_CONFIG_BODY
public static final Relationship REL_SUCCESS
private Set<Relationship> relationships
private List<PropertyDescriptor> properties
private final org.apache.tika.config.TikaConfig config
private org.apache.tika.detect.Detector detector
private org.apache.tika.mime.MimeTypes mimeTypes
protected void init(ProcessorInitializationContext context)
init in class AbstractSessionFactoryProcessor@OnScheduled public void setup(ProcessContext context)
public Set<Relationship> getRelationships()
getRelationships in interface ProcessorgetRelationships in class AbstractSessionFactoryProcessorprotected List<PropertyDescriptor> getSupportedPropertyDescriptors()
getSupportedPropertyDescriptors in class AbstractConfigurableComponentpublic void onTrigger(ProcessContext context, ProcessSession session)
onTrigger in class AbstractProcessorprotected Collection<ValidationResult> customValidate(ValidationContext validationContext)
customValidate in class AbstractConfigurableComponentCopyright © 2023 Apache NiFi Project. All rights reserved.