The FTPS Connector allows you to send and receive files over FTP on top of a TLS/SSL connection.
Table of Contents
Introduction
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:
Prerequisites
This document assumes that you are familiar with Mule, the Anypoint™ Studio interface, and Global Elements. Further, it is assumed that you are familiar with the FTP and TLS protocols.
Requirements
Installing and Configuring
Installing
Configuring
In order to set FTPS configuration you must first know your endpoint configuration needs. See Hello World sample project below for configuration example.
Updating From an Older Version
This is currently the first version of the connector.
Using This Connector
Use Cases
Tips
Whenever possible, use passive mode. It’s easier to set up from the client 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.
Increasing Performance
The FTPS Connector supports compression out-of-the-box. If your FTP server supports deflate mode (a.k.a "mode z") the FTPS Connector will detect this feature and enter in compression mode for you.
Example Use Cases
The following example explains the configuration options of the FTPS Connector for sending and receiving files.
This sample will receive a file over FTPS by its full name and save it’s 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 a FTPS connector over to the canvas:
Create a connector configuration for the FTPS element
Step 5
Set the FTPS settings according to your scenario. In this sample, we have an FTPS server running on localhost.
B2B settings
Activate this option if the Global configuration options are being set using a B2B Provider.
General FTP settings
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 Active Mode tab if you go for active.
If you want to use explicit mode, select EXPLICIT in the Encryption mode field.
Security - Certificates (Optional)
If set, the FTPS connector will validate 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.
Security - FTP
Your user and password on the FTP server.
Now let’s setup the connector’s Read File operation to retrieve a file securely from the FTP Server. File contents will be passed over to the next component in the flow.
Basic Settings
Select the Read operation
General Options
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.
Post-processing
After a file has been read, the connector will attempt to delete it from the server unless Move to Directory is set to an existing location on the server. This field is optional.
Polling
The connector polls the server for the specified file. By default it checks for the file every second. Once it gets it it will continue to read the file and inject it into the flow.
B2B options
The specification ID for inbound transactions set on the B2B platform. This field is required if the Use B2B Provider was checked in the global configuration.
Now it’s up to you to decide what to do with the contents you just read. What we’re going to do is 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 file name 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 sample will write a file over FTPS using the contents received in the payload.
Same as in the previous example.
Drag and drop the a File component into the canvas. Set it up to read any given file from your filesystem.
Drag and drop the FTPS connector icon over the canvas, right next to the File component of the previous step. This is how it should look like:
Now let’s 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.
General options
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.
B2B options
The specification ID for outbound transactions set on the B2B platform. This field is required if the Use B2B Provider was checked in the global configuration.
Save your changes, run the application and you’re done. The application should have written your file to the server under the name specified in the configuration.
This sample will receive one or more files over FTPS filtering by a wildcard pattern.
Same as in the previous example.
Now let us setup the connector’s Read operation to retrieve a set of files securely from the FTPS server, but this time use a wildcard in the filename.
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’s see an example of how to use the files we’ve just read. Drag and drop a File connector and set it up like this:
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 will read files from the server matching the filename pattern and save them locally under the same filename they had on the server.