Skip to main content

FetchFile

Description

Reads the contents of a file from disk and streams it into the contents of an incoming FlowFile. Once this is done, the file is optionally moved elsewhere or deleted to help keep the file system organized.

Tags

fetch, files, filesystem, get, ingest, ingress, input, local, source

Properties

In the list below required Properties are shown with an asterisk (*). Other properties are considered optional. The table also indicates any default values, and whether a property supports the NiFi Expression Language.

Display NameAPI NameDefault ValueAllowable ValuesDescription
File to Fetch *File to Fetch${absolute.path}/${filename}The fully-qualified filename of the file to fetch from the file system

Supports Expression Language, using FlowFile attributes and Environment variables.
Completion Strategy *Completion StrategyNone
  • None
  • Move File
  • Delete File
Specifies what to do with the original file on the file system once it has been pulled into NiFi
Move Destination DirectoryMove Destination DirectoryThe directory to the move the original file to once it has been fetched from the file system. This property is ignored unless the Completion Strategy is set to "Move File". If the directory does not exist, it will be created.

Supports Expression Language, using FlowFile attributes and Environment variables.
Move Conflict Strategy *Move Conflict StrategyRename
  • Rename
  • Replace File
  • Keep Existing
  • Fail
If Completion Strategy is set to Move File and a file already exists in the destination directory with the same name, this property specifies how that naming conflict should be resolved
Log level when file not found *Log level when file not foundERROR
  • TRACE
  • DEBUG
  • INFO
  • WARN
  • ERROR
  • FATAL
  • NONE
Log level to use in case the file does not exist when the processor is triggered
Log level when permission denied *Log level when permission deniedERROR
  • TRACE
  • DEBUG
  • INFO
  • WARN
  • ERROR
  • FATAL
  • NONE
Log level to use in case user runner does not have sufficient permissions to read the file

Dynamic Properties

This component does not support dynamic properties.

Relationships

NameDescription
failureAny FlowFile that could not be fetched from the file system for any reason other than insufficient permissions or the file not existing will be transferred to this Relationship.
not.foundAny FlowFile that could not be fetched from the file system because the file could not be found will be transferred to this Relationship.
permission.deniedAny FlowFile that could not be fetched from the file system due to the user running NiFi not having sufficient permissions will be transferred to this Relationship.
successAny FlowFile that is successfully fetched from the file system will be transferred to this Relationship.

Reads Attributes

This processor does not read attributes.

Writes Attributes

This processor does not write attributes.

State Management

This component does not store state.

Restricted

Required PermissionExplanation
read filesystemProvides operator the ability to read from any file that NiFi has access to.
write filesystemProvides operator the ability to delete any file that NiFi has access to.

Input Requirement

This component requires an incoming relationship.

Example Use Cases Involving Other Components

Multiprocessor Use Case 1

Ingest all files from a directory into NiFi

Components Involved

  • ListFile
    1. Configure the "Input Directory" property to point to the directory that you want to ingest files from.
    2. Set the "Input Directory Location" property to "Local"
    3. Optionally, set "Minimum File Age" to a small value such as "1 min" to avoid ingesting files that are still being written to.
    4. Connect the 'success' Relationship to the FetchFile processor.
  • FetchFile
    1. Set the "File to Fetch" property to ${absolute.path}/$\{filename}
    2. Set the "Completion Strategy" property to None

Multiprocessor Use Case 2

Ingest specific files from a directory into NiFi, filtering on filename

Components Involved

  • ListFile
    1. Configure the "Input Directory" property to point to the directory that you want to ingest files from.
    2. Set the "Input Directory Location" property to "Local"
    3. Set the "File Filter" property to a Regular Expression that matches the filename (without path) of the files that you want to ingest. For example, to ingest all .jpg files, set the value to .*\.jpg
    4. Optionally, set "Minimum File Age" to a small value such as "1 min" to avoid ingesting files that are still being written to.
    5. Connect the 'success' Relationship to the FetchFile processor.
  • FetchFile
    1. Set the "File to Fetch" property to ${absolute.path}/$\{filename}
    2. Set the "Completion Strategy" property to None

System Resource Considerations

This component does not specify system resource considerations.

See Also

GetFile, ListFile, PutFile