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

    Fields
    Modifier and Type
    Field
    Description
    private final org.apache.tika.config.TikaConfig
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    static final org.apache.nifi.components.PropertyDescriptor
     
    private static final String
     
    private static final String
     
    private org.apache.tika.detect.Detector
     
    private org.apache.tika.detect.EncodingDetector
     
    (package private) static final org.apache.nifi.components.AllowableValue
     
    private org.apache.tika.mime.MimeTypes
     
    (package private) static final org.apache.nifi.components.AllowableValue
     
    private static final List<org.apache.nifi.components.PropertyDescriptor>
     
    static final org.apache.nifi.processor.Relationship
     
    private static final Set<org.apache.nifi.processor.Relationship>
     
    (package private) static final org.apache.nifi.components.AllowableValue
     
    static final org.apache.nifi.components.PropertyDescriptor
     
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    private org.apache.tika.mime.MimeTypes
    createCustomMimeTypes(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 Charset
    identifyCharset(org.apache.tika.io.TikaInputStream tikaStream, org.apache.tika.metadata.Metadata metadata, org.apache.tika.mime.MediaType mediaType)
     
    private String
    lookupExtension(String mediaTypeString, org.apache.nifi.logging.ComponentLog logger)
     
    void
     
    void
    onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
     
    void
    setup(org.apache.nifi.processor.ProcessContext context)
     

    Methods inherited from class org.apache.nifi.processor.AbstractProcessor

    onTrigger

    Methods inherited from class org.apache.nifi.processor.AbstractSessionFactoryProcessor

    getControllerServiceLookup, getIdentifier, getLogger, getNodeTypeProvider, init, initialize, isConfigurationRestored, isScheduled, toString, updateConfiguredRestoredTrue, updateScheduledFalse, updateScheduledTrue

    Methods inherited from class org.apache.nifi.components.AbstractConfigurableComponent

    equals, getPropertyDescriptor, getPropertyDescriptors, getSupportedDynamicPropertyDescriptor, hashCode, onPropertyModified, validate

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait

    Methods inherited from interface org.apache.nifi.components.ConfigurableComponent

    getPropertyDescriptor, getPropertyDescriptors, onPropertyModified, validate

    Methods 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

      private static final List<org.apache.nifi.components.PropertyDescriptor> PROPERTY_DESCRIPTORS
    • REL_SUCCESS

      public static final org.apache.nifi.processor.Relationship REL_SUCCESS
    • RELATIONSHIPS

      private static final Set<org.apache.nifi.processor.Relationship> RELATIONSHIPS
    • CUSTOM_MIME_TYPES_FILENAME

      private static final String CUSTOM_MIME_TYPES_FILENAME
      See Also:
    • DEFAULT_MIME_TYPES_PATH

      private static final String 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

      public void migrateProperties(PropertyConfiguration config)
    • setup

      @OnScheduled public void setup(org.apache.nifi.processor.ProcessContext context) throws IOException
      Throws:
      IOException
    • getRelationships

      public Set<org.apache.nifi.processor.Relationship> getRelationships()
      Specified by:
      getRelationships in interface org.apache.nifi.processor.Processor
      Overrides:
      getRelationships in class org.apache.nifi.processor.AbstractSessionFactoryProcessor
    • getSupportedPropertyDescriptors

      protected List<org.apache.nifi.components.PropertyDescriptor> getSupportedPropertyDescriptors()
      Overrides:
      getSupportedPropertyDescriptors in class org.apache.nifi.components.AbstractConfigurableComponent
    • onTrigger

      public void onTrigger(org.apache.nifi.processor.ProcessContext context, org.apache.nifi.processor.ProcessSession session)
      Specified by:
      onTrigger in class org.apache.nifi.processor.AbstractProcessor
    • lookupExtension

      private String lookupExtension(String mediaTypeString, org.apache.nifi.logging.ComponentLog logger)
    • 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:
      customValidate in class org.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.MimeTypeException
      IOException