The FTPS Connector allows you to send and receive data over the FTPS protocol.
The FTPS Connector allows you to send and receive files over FTP on top of a TLS/SSL connection.
After reading this page you should be able to accomplish the following:
Install the FTPS Connector.
Configure the FTPS Connector to fit your needs.
Build a Hello World project.
Run the example project.
This document assumes that you are familiar with Mule and the Anypoint Studio interface. Furthermore, it is assumed that you are familiar with FTPS.
1 2 3 4 5 xmlns:ftps="http://www.mulesoft.org/schema/mule/ftps" Schema Location xsi:schemaLocation=" ... http://www.mulesoft.org/schema/mule/ftps http://www.mulesoft.org/schema/mule/ftps/current/mule-ftps.xsd"
To install the FTPS Connector in Anypoint Studio, see Installing a Connector from Anypoint Exchange.
If you wish to use the FTPS Module in conjunction with Maven, please follow the instructions here.
To configure the FTPS connector, determine your endpoint configuration needs. See the Hello World application below for a configuration example.
Read file(s) over FTPS, alternatively using a wildcard pattern
Write file over FTPS
Transfer files using Active and Passive FTP modes
Transfer files using Explicit and Implicit SSL modes
Use passive mode whenever possible. It is easier to set up from the client’s perspective.
Polling the server is possible from the FTPS connector itself; there’s no need to use a Poll component. This is useful when waiting for a given file to be published by others.
The FTPS Connector supports compression out-of-the-box. If your FTP server supports deflate mode (a.k.a “mode z”), the FTPS Connector detects this feature and enters compression mode for you.
The following examples explain the FTPS Connector configuration options for sending and receiving files.
Learn how to:
Receive a file over FTPS
Write a file on the server over FTPS
Receive one or more files over FTPS filtering by wildcard pattern
In this example, the connector reads a file over FTPS and saves its contents locally.
Create a new Mule Project using as run-time Mule Server 3.6.0 EE:
Locate the FTPS Connector on the right hand-side palette:
Drag and drop the FTPS connector over to the canvas:
Create a connector configuration for the FTPS element
Set the FTPS settings according to your scenario. In this example, we have an FTPS server running on localhost.
Set the host of your FTP server, this can be an IP address or a host name. Set the port the FTP server is listening to (control channel). Set whether you prefer active or passive connection modes. Fill in the blanks in the Advanced tab if you go for active. If you want to use explicit mode, select EXPLICIT in the Encryption mode field. The Streaming option is suitable for large files; instead of reading the contents to a byte array in memory; an input stream is passed as the payload to the next component in the flow.
Security - FTP
Your username and password on the FTP server.
Advanced settings can also be applied if needed. Read below for a brief description for each.
Security - Certificates (Optional)
If set, the FTPS connector validates your server’s identity with these certs. Only JKS format is supported at the moment. _If you want to disable server certificate validation, you’ll be able to find that option in this section as well, although it’s not recommended.
Active Mode settings
These fields are going to be read in case ACTIVE was selected as Transfer Mode. The Reported IP Address is the external IP address to use if your application runs within a LAN and the FTP server is external to it.
The Upload temp directory sets the location on the server side where the files are going to be uploaded before they reach they final destination.
The number of worker threads to use when downloading multiple files (useful when reading files using a wildcard pattern or a directory).
Now let’s set up the connector’s Read File operation to retrieve a file securely from the FTP Server. File contents are passed to the next processor in the flow.
Select the Read operation
Enter the path and filename of the file you aim to read from the server. In our case we’re transferring modus-test-read.txt which is located at the /demo directory of the FTP user we’ve set.
After a file has been read, the connector attempts to delete it from the server unless Move to Directory is set to an existing location on the server. This field is optional.
The connector polls the server for the specified file. By default it checks for the file every second. Once it gets it it continues to read the file and inject it into the flow.
Now it’s up to you to decide what to do with the contents you’ve just read. In this example, we’re going to write the contents to a file. The FTPS connector can help us with that as it gives us 2 extra bits of information: the original filename and its size.
You should have your application ready to read a file securely from a FTP server you trust.
Finally, run the example as a Mule application:
If the file exists on the remote FTP server, the Connector should read it and locate it under the /tmp folder as setup in Step 7.
This example writes a file over FTPS using the contents received in the payload.
Steps 1 - 5
Follow steps 1-5 in the above example.
Drag and drop the File message source into the canvas. Set it up to read any given file in your filesystem.
Drag and drop the FTPS connector icon over the canvas, next to the File message source. This is how it should look like:
Now let us set up the FTPS write file operation.
As you can see, we’re reusing the Global Configuration element from the previous example. Review Step 5 of the previous example for further details.
As in the Read operation you can select which path to upload your file to. Under Filename you can enter any MEL expression you want; we’re setting a fixed name for simplicity.
Save your changes and run the application. The application writes your file to the FTPS server under the name specified in the configuration.
This example receives one or more files over FTPS filtering by a wildcard pattern.
Steps 1 - 5
Same as in the previous example.
Now let us setup the connector’s Read File using Pattern operation to retrieve a set of files securely from the FTPS server. Every time a file matches the pattern, the set up flow activates with the contents of the file.
Enter the path of the parent directory you aim to read the files from on the server.
Enter the File pattern as well; bear in mind this is a wildcard pattern. In our case we’re transferring every file that starts with “modusbox-”.
Let us see an example of how to use the files we have just read. Drag and drop a File connector and set it up as follows:
The above screenshot shows that the files are saved in our local /tmp directory. Take a look at the File Name/Pattern configuration value. The fileName inbound property is added by the FTPS connector along with the fileSize property. These values can come in handy for when you need to deal with multiple files.
Save your changes and run the application. The application reads files from the server matching the filename pattern and saves them locally under the same filename they had on the server.