doc/index.adoc
== Adapter Inbound File
This adapter open file streams and send them out as messages.
It could listen on directories for new files or it could be externally triggered.
=== Configuration
The configuration for this step is as follows.
.Message formats
[source,js]
----
{
"regEx" : ".*\\.csv", <1>
"filter": filterFunction, <2>
"watchDir": directory <3>
"onlyReadNewFiles" : true <4>
}
----
<1> (Optional) A regular expression which will be matched against the file names changed. If the regEx did not
match no message will be generated.
<2> (Optional) A custom function to filter the file names. The function looks like ''function (fileName){return true}''.
The function gets the file name as parameter and must return true or false.
<3> (Optional) The directory which should be watched for changes.
<4> (Optional) If set to true (default) then only new files added will be send. Else it will also
send the already existing files.
=== Endpoints
This Adapter has two endpoints. One 'out' endpoint which send out the messages with
the red stream and one 'in' endpoint for external trigger events.
==== out
This endpoint send out file read messages.
.Endpoint description
[options="header", cols="2"]
|====
|Description|Value
|*Name*|out
|*Direction*|out
|*Active*|true
|*Passive*|false
|====
.Message Format
[source,js]
----
{
"header": {
"file_name": fileName, <1>
"directory": directory, <2>
"file_stat": stat <3>
},
"payload": stream <4>
}
----
<1> The Name of the file. Without the path.
<2> The directory the file is in. Full qualified name.
<3> The file stat as generated by 'fs.stat'.
<4> The opene read stream to the file
==== inFileTrigger
This endpoint could be used to trigger files for reading.
.Endpoint description
[options="header", cols="2"]
|====
|Description|Value
|*Name*|inFileTrigger
|*Direction*|in
|*Active*|false
|*Passive*|true
|====
.Message formats
[source,js]
----
{
"header": {},
"payload": filename <1>
}
{
"header": {},
"payload": [file1, fileN] <2>
}
{
"header": {},
"payload": {
"directory" : directory, <3>
"files" : file <4>
}
}
{
"header": {},
"payload": {
"directory" : directory,
"files" : [file1, fileN] <5>
}
}
----
<1> The payload has just one file name. This file name must be a full qualified file name.
<2> The payload has a list of full qualified file names.
<3> The payload is an object. This is the directory containing the files. If a directory is
given the filenames may be relative to this directory.
<4> One single file.
<5> An array of files.