The From FTP Reader component is a simple example component that connects with a FTP, FTPS, or SFTP server and retrieves files from a target directory for processing. As each file is read, its contents will be pushed downstream for further processing, and the original file will be either deleted These files are downloaded to a local folder and then either deleted from the server or moved to a designated folder on the server. The downloaded files are then read and pushed downstream for further processing in the same way the https://interfaceware.atlassian.net/wiki/x/AQDqsw processes files.
By default, this component polls every 60 seconds.
Running the Component
Info |
---|
The below steps assume an existing FTP/FTPS/SFTP server is available to connect to and the necessary user permissions and folder structure are in place on the FTP server and locally. |
Expand |
---|
title | STEP 1: Import the File Retriever From FTP component |
---|
|
Using +COMPONENT, import the From FTP Readercomponent. |
Expand |
---|
title | STEP 2: Set up the component configurations |
---|
|
Image Added Fields marked with an asterisk * are required. Connection Configurations: Protocol: specify Default Value |
---|
Protocol * | Specifies the protocol you’ll be using |
(. Supports: FTP, FTPS, or SFTP |
): the server you’ll * | The server you will be connecting with |
Port: the - | Port * | The port to use | - | Username |
: the * | The remote user to login as. This account will need permissions to read, delete, and/or move files to the specified |
SourceDir: the | The password to authenticate with. | - | Certificate | The name of your certificate file, if in use. By default, this should be a PEM certificate. The default configurations can be changed by modifying the net.[protocol].init function directly in the script. See Adapting the Component. This configuration is only applicable for FTP and FTPS. | - |
RetryCount: the PrivateKey | The name of your private key file, if in use. By default, this should be a PEM certificate and not be password-locked. The default configurations can be changed by modifying the net.[protocol].init function directly in the script. See Adapting the Component. | - | RetryCount | The number of times to retry the connection if it drops. |
By default, it will retry 10 times.Workflow Configurations SourceDir: the source directory Default is set to 3 attempts. | 3
|
FTP Workflow Configurations: Field | Description | Default Value |
---|
FTPDirectory * | The source directory on the FTP server you’ll be retrieving files from |
FileExtension: the FTP
| FileType | The types of files you wish to retrieve (e.g. txt) |
DeleteProcessedFiles: set . You can also specify multiple files (e.g. txt,hl7) or all file types (e.g. *). | - | MoveFTPProcessedFiles | Set to true if you wish to |
delete processed filesmove processed files (i.e. files that have already been downloaded to the local server) to a folder on the FTP server designated by FTPProcessedDirectory. If false, processed files will be deleted. | true
| FTPProcessedDirectory | The directory on the FTP server that processed files will be moved into. You will need to create this folder if you choose to use this workflow. | - |
Local File Workflow Configurations: ProcessedFileDir: the directory on the server that Field | Description | Default Value |
---|
LocalDirectory * | The local directory that the files will be downloaded to from the FTP server. Files in this directory will then be picked up for processing. | - | MoveProcessedFiles | Set to true if you wish to move processed files to a local folder designated by |
ProcessedFileDir. This is set to false by default.ProcessedDirectory. If false, processed files will be deleted. | true
| ProcessedDirectory | The local directory that processed files will be moved |
tointo. You will need to create this folder if you choose to use this workflow. | - | MinimumFileAge * | The time to wait in seconds after last modified date before processing. | 0
| IgnoreSegments * | Specifies whether to remove identified segments when processing file. Default segments to ignore include: FHS, BHS, FTS, BTS. This can be modified in config.lua. See Adapting the Component. | false
| InputFileEncoding * | The encoding used in the output file. If left blank, encoding will be updated to the default according to OS. See Supported File Encodings | Western (Windows-1252) for Windows
Western (ISO-8859-1) for Linux/Mac OS
|
|
Expand |
---|
title | STEP 3: Start the component and view the processed files' contents in the logs |
---|
|
Once the component has been started, it will pull download files that match the provided parameters to the specified local directory. It will then process the downloaded files and push their contents to the component’s queue for further processing. Open the component’s logs to see the queued files and verify that the contents are being read as expected. |
Adapting the Component
There are a few ways you can adapt and expand this component for more complex workflows:
...
Expand |
---|
title | Customize the FTP/FTPS/SFTP connection |
---|
|
By default, the FTP/FTPS/SFTP connection is authenticated using username and password authentication and uses the default configurations. In some cases, additional configurations may be desired, such as: Specifying a FTP(S) modeProviding certificates Using public and private key authentication Disabling verify_peer or verify_host Increasing the timeout and more. Full details can be found by accessing the net.ftp.init, net.ftps.init, or net.sftp.init function help in the Translator
These configurations can be customized by modifying the input parameters to the net.*.init function in the main function: Image RemovedInput parameter table in the loadConfigs() function in FTP/FTPprocess.lua: Image Added |
Expand |
---|
title | Add more file retrieval conditions |
---|
|
Currently, the component retrieves files from the FTP server based on the these two conditions: The file is retrievable The file extension matches the provided extension (e.g. txt)
This is typically sufficient for most cases, but if additional conditions are needed, they can be added to the MatchRules function as shown below: Image RemovedFTPmatchRules function in FTP/FTPmatchRules.lua: Image Added |
Expand |
---|
title | Customize the ignored segments or message delimiter via config.lua |
---|
|
Ignored segments: the ignored segments list can be modified to remove additional segments from a message when IgnoredSegments = true Replace message delimiter: replaces the delimited at the end of the message with ‘\n’
|