File component
The File component interacts with the internal file system to read or write files. It can act as either an outbound (writing files) or inbound component (reading files).
When it is not the first component in a flow, it acts as an outbound component (writing files) by default.
Use the File component in outbound mode with caution, it's possible that the server runs out of diskspace which can cause other problems.
Configuration
The File component has the following configuration options:
Force inbound
This option is only available when the File component is not the first component in a flow. It overrides the default outbound (writing files) behavior and forces the component into inbound (reading files) mode.
- Only one file at a time is consumed when the component is forced into inbound mode.
- The message body before the File component is replaced with the content of the consumed file.
Headers containing file-related information, such as filename and filesize, are set after reading a file. Refer to the Camel documentation File - Message headers for a detailed explanation.
Path
Specifies the target directory path to read from (inbound mode) or write to (outbound mode).
File name
Specifies the exact filename to read (inbound mode) or write (outbound mode)
Charset
Specifies the file encoding.
When writing large text files such as XML or JSON, you may choose to leave this option empty. The file will be processed as binary and its content does not have to be read into memory to validate the charset. This greatly improves performance and can prevent errors when parsing the file later.
Auto create
Specifies whether missing directories in the file path should be created automatically.
Options
Yes
(default)No
Only available when the component is in outbound mode.
Recursive
Specifies if only files in the specified path should be read ()No
) or if files in all subdirectories should be included (Yes
).
Options
Yes
No
(default)
If this option is set to Yes
you must ensure that your Exclude regex ignores the directory where processed files are placed. Otherwise, you may create an infinite loop.
Only available when the component is set to inbound mode.
Delete file
Specifies wether files are deleted after processing.
Options
Yes
No
(default)
Only available when the component is set to inbound mode.
File exist
Specifies what to do if a file with the same name already exists.
Options
Override
(default)Append
Ignore
Fail
Only available when the component is in outbound mode.
Include
Include files if their filename matches the specified regular expression (regex) pattern.
Only available when the component is in inbound mode.
Exclude
Exclude files if their filename matches the specified regular expression (regex) pattern.
Only available when the component is in inbound mode.
Initial delay
The amount of time (in milliseconds) to wait before the 'polling' of files/directories starts.
- Default:
60000
(60 seconds) - Minimum:
1000
(1 second)
Only available when the component is set to inbound mode.
Delay
The amount of time (in milliseconds) to wait before the next poll of the file/directory.
- Default:
60000
(60 seconds) - Minimum:
500
(0.5 seconds)
Only available when the component is set to inbound mode.