Getting started with the FTP Connector for MuleSoft

Requirements: /n software Connectors for MuleSoft

Introduction

The /n software Connectors for MuleSoft include pure java Connectors and Modules designed to seamlessly integrate with MuleSoft. The /n software Connectors for MuleSoft extend the functionality of MuleSoft and provide robust enterprise ready enterprise ready Internet connectivity, secure messaging, and file transfer.

This guide will focus on the basics of the FTP Connector, which is used to communicate with FTP servers. The FTP Connector supports FTPS (FTP over SSL). For details on installation and other connectors please see the Online Documentation.

Contents

FTP Receiver Properties

Core Properties

To use an FTP Receiver instance to a MuleSoft project, there are a few core properties that must be set:

PropertyDescription
FTP ServerThe remote FTP host address
FTP PortThe port on which to connect
UserThe User credential for performing FTP logon
PasswordThe Password for the specified User
Remote PathThe path on the FTP host from which files should be downloaded
File MaskAn optional mask for the files at the Remote Path

Together, these properties determine the location (and credentials for that location) from which files will be received.

SSL Properties

For secure FTP transfer, SSL properties should also be set. The SSL Start Mode property determines whether and how the connector will attempt to negotiate SSL with the remote host. If set to None, the connection will be made over plaintext (no encryption). If set to Implicit, the SSL negotiation will begin immediately after establishing a connection to the server. If set to Explicit, SSL negotiation will occur after connecting to the server and asking for an SSL-secured session via the AUTH TLS command. If set to Automatic, SSL will be negotiated implicitly when connecting to the expected SSL FTP port (990) and explicitly otherwise.

The SSL Server Cert property consists of a collection of fields that determine whether the connector should trust the SSL certificate presented by the server (this property may need to be set to Edit inline for the collection of fields to appear). The simplest approach is to set SSL Accept Server Cert Accept Any to True, which causes the connector to accept any SSL certificate presented by the specified FTP Server. For more control, the specific certificate expected from the server can be set via the combination of SSL Accept Server Cert Store Type, SSL Accept Server Cert Store, SSL Accept Server Cert Store Password, and SSL Accept Server Cert Subject.

Similarly, the SSL Cert property consists of a collection of fields that determine the client SSL certificate; this is only necessary if client authentication is required for the specified FTP Server. The certificate is set via the combination of SSL Cert Store Type, SSL Cert Store, SSL Cert Store Password, and SSL Cert Subject.

FTP Receiver Usage

Dragging an instance of the FTP Receiver into a Mule project will automatically establish an FTP Source Connector. A configuration must be applied to the connector, including the core properties mentioned in the previous section. Additionally the polling settings should be configured in the general connector settings pane.

The connector will poll the specified FTP Server at the specified Remote Path for any files matching the File Mask. Any files found will be sent through the MuleSoft message pipeline. The Delete Mode property can be set if files should be deleted after downloading.

After download, the files enter the Mule message flow. After the FTP Receiver passes the file data off to another component within the Mule flow, certain attributes of the file are available. In Mule 3.X, these message context attributes are accessed by referencing the inboundProperties of the message e.g. message.inboundProperties.ReceivedFileName. In Mule 4.X, these properties are available through the attributes keyword, e.g. attributes.ReceivedFileName.

Here is an example of a simple flow that receives files from an FTP Server and writes them to the local drive:

An example FTP Receive flow and configuration

FTP Sender Properties

Core Properties

To use an FTP Sender instance in a MuleSoft project, a set of core properties must be set, similar to the Receiver:

PropertyDescription
FTP ServerThe remote FTP host address
FTP PortThe port on which to connect
UserThe User credential for performing FTP logon
PasswordThe Password for the specified User
Remote PathThe path on the FTP host where the files should be uploaded
Remote FileThe name of the file once uploaded to the remote host

Together, these properties determine the location and name of the uploaded file(s). If files should retain their original name after upload, this can be accomplished by using the message context properties in the Remote File property. In Mule 3.X this should be set to #[message.inboundProperties.ReceivedFileName]. In Mule 4.X, the corresponding syntax is #[attributes.ReceivedFileName].

SSL Properties

For secure FTP transfer, SSL properties should also be set. The SSL Start Mode property determines whether and how the connector will attempt to negotiate SSL with the remote host. If set to None, the connection will be made over plaintext (no encryption). If set to Implicit, the SSL negotiation will begin immediately after establishing a connection to the server. If set to Explicit, SSL negotiation will occur after connecting to the server and asking for an SSL-secured session via the AUTH TLS command. If set to Automatic, SSL will be negotiated implicitly when connecting to the expected SSL FTP port (990) and explicitly otherwise.

The SSL Server Cert property consists of a collection of fields that determine whether the connector should trust the SSL certificate presented by the server (this property may need to be set to Edit inline for the collection of fields to appear). The simplest approach is to set SSL Accept Server Cert Accept Any to True, which causes the connector to accept any SSL certificate presented by the specified FTP Server. For more granular control, the specific certificate expected from the server can be set via the combination of SSL Accept Server Cert Store Type, SSL Accept Server Cert Store, SSL Accept Server Cert Store Password, and SSL Accept Server Cert Subject.

Similarly, the SSL Cert property consists of a collection of fields that determine the client SSL certificate; this is only necessary if client authentication is required for the specified FTP Server. The certificate is set via the combination of SSL Cert Store Type, SSL Cert Store, SSL Cert Store Password, and SSL Cert Subject.

FTP Sender Usage

Dragging an instance of the FTP Sender into a Mule project will automatically establish an FTP Process Connector. A Process Connector receives data from Source Connectors (with possible intermediary steps), and the FTP Connector processes data by uploading it to remote FTP hosts. A configuration must be applied to the connector, including the core properties mentioned in the previous section.

Whenever a Mule message is provided to the connector during the MuleSoft flow, the connector will connect to the specified FTP Server and upload the data at the location given by Remote Path and Remote File. The Overwrite property can be set if files should be uploaded even if a file of the same name already exists on the server.

Below is an example of a simple flow that receives files from an FTP Server and then uploads them to a different location on the FTP Server. You can imagine that the files are processed during the MuleSoft flow (not shown) and then uploaded back to an archive location.

An example FTP Sender flow and configuration

We appreciate your feedback.  If you have any questions, comments, or suggestions about this article please contact our support team at kb@nsoftware.com.