We’ve added an SFTP node to our IBM App Connect library for performing file-based operations using the Secure File Transfer Protocol.
The SFTP node supports the following events and actions:
SFTP connection details
You can connect to cloud-based SFTP servers, or on-premises SFTP servers that are on a private network (by using an IBM secure gateway).
The connection details required to connect to an SFTP server are as follows:
Actions supported for files
- Create file
- Download file
- Rename file
Create file
This action can be used to create a file in a folder, and requires three parameters:
- Type of file – Either ‘text’ or ‘binary’. Select one option from the drop-down list depending on the type of file that needs to be created.
- Source path – The absolute path of the file (including the file name) that is to be created.
- File data – Data that needs to be written into the file created.
Download file
This action can be used to download or get the contents of a file in a folder, and requires two parameters:
- Type of file – Either ‘text’ or ‘binary’. Select one option from the drop-down list depending on the type of file that needs to be downloaded.
- Source path – The absolute path of the file (including the file name) that needs to be downloaded.
Note: The maximum size of a file that can be downloaded is 10 MB.
Rename file
This action can be used to rename a file in a folder, and requires two parameters:
- Source path – The absolute path of the file (including the file name) that needs to be renamed.
- Destination path – The absolute path (including the file name) where the renamed file should be stored.
For example, you can specify the following values to indicate that file sampleFile.txt
, which is under the root folder, should be renamed to sampleFile_new.txt
.
Source path: /root/sampleFile.txt
Destination path: /root/sampleFile_new.txt
Actions supported for folders
- Create folder
- Rename folder
Create folder
This action can be used to create a folder on an SFTP server, and requires one parameter:
- Source path – The absolute path of the folder (including the folder name) that needs to be created.
Rename folder
This action can be used to rename a folder on an SFTP server, and requires two parameters:
- Source path – The absolute path of the folder (including the folder name) that needs to be renamed.
- Destination path – The absolute path of the renamed folder.
For example, you can specify the following values to indicate that folder AppConn
, which is under the root folder, should be renamed to AppConnLatest
.
Source path: /root/AppConn
Destination path: /root/AppConnLatest
Actions supported for folder items
Retrieve folder items
This action can be used to retrieve the list of items in a folder on an SFTP server. This would give you the list of files and folders (with their metadata) that are present in a folder, and requires one parameter:
- Parent path – The absolute path of the folder whose list of items are required.
Events supported as triggers for the SFTP node
You can configure the SFTP node to monitor the root or parent folder of an SFTP server, and trigger a flow if a new folder item (folder or file) is created, or if any folder item is updated. If you select the “New or updated Folder item” event, you’ll see the following configuration fields:
We suggest that you accept the default values for all fields except for this one:
- Check for new ‘folderitem’ every (minutes) – Select one of the values from the drop-down list to specify the polling interval in minutes.
Example flow
In the following sample flow, we’ve added an event and actions to read a new file, parse it, create or update contacts in a Salesforce account using the parsed contents, and finally rename the file.
The first node is an SFTP event. It triggers the flow whenever there is a new or updated file in the root or parent folder.
The second node is configured to download and read the contents of the file that was added or updated. This example uses a comma-separated values (CSV) file, which has a file type of text. We can map the path of the file from the event node.
For the third node, we’ve added a CSV Parser to parse the contents of the downloaded CSV file.
Next, is a ‘For each’ node containing a Salesforce ‘Update or create contact’ action.
The ‘For each’ node loops through all the records in the CSV file and creates or updates a contact in Salesforce, for each row in the file. Fields are mapped appropriately from the CSV Parser node to create or update a contact.
The last node is configured to rename the file on the SFTP server (after the file is downloaded), to symbolize that it has been processed.