ModusBox's FTPS Connector

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:

  • Install the FTPS Connector.
  • Adjust the FTPS Connector to fit your needs.
  • Build a simple Hello World project.
  • Run the example project.

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


  • Mule 3.6.0 server Runtime
  • Anypoint Studio January 2015 onwards

Installing and Configuring


Installing

  1. Launch Anypoint Studio and click on Help -> Install New Software.
  2. Press Add to create a new repository.
  3. Type in "FTPS Connector" in the Name field and click on Archive
  4. Select the FTPS Connector Eclipse "UpdateSite.zip" distributed by ModusBox Inc. and press Open.
  5. Expand Premium and select FTPS Connector. Press Next > to review the items to be installed.
  6. Press Next > again to review and accept the license. Press Finish to install the connector.
  7. Press OK to accept the prompted security dialog box and allow Anypoint Studio to restart.

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

  • 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

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


* Receive a file over FTPS * Write a file on the server over FTPS * Receive one or more files over FTPS filtering by wildcard pattern

The following example explains the configuration options of the FTPS Connector for sending and receiving files.

Receive a file over FTPS

This sample will receive a file over FTPS by its full name and save it’s contents locally.

**Step 1**

Create a new Mule Project using as run-time Mule Server 3.6.0 EE:

image alt text

**Step 2**

Locate the FTPS Connector on the right hand-side palette:

image alt text

**Step 3**

Drag and drop a FTPS connector over to the canvas:

image alt text

**Step 4**

Create a connector configuration for the FTPS element

image alt text

Step 5

Set the FTPS settings according to your scenario. In this sample, we have an FTPS server running on localhost.

image alt text

  1. B2B settings
    Activate this option if the Global configuration options are being set using a B2B Provider.

  2. 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.

  3. 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.

  4. Security - FTP
    Your user and password on the FTP server.

**Step 6**

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.

image alt text

  1. Basic Settings
    Select the Read operation

  2. 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.

  3. 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.

  4. 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.

  5. 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.

**Step 7**

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.

image alt text

You should have your application ready to read a file securely from a FTP server you trust.

**Step 8**

Finally, run the example as a Mule application:

image alt text

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.

Write a file on the server over FTPS

This sample will write a file over FTPS using the contents received in the payload.

**Steps 1 - 5**

Same as in the previous example.

**Step 6**

Drag and drop the a File component into the canvas. Set it up to read any given file from your filesystem.

**Step 7**

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:

image alt text

**Step 8**

Now let’s set up the FTPS write file operation.

image alt text

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.

  1. 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.

  2. 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.

**Step 9**

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.

Receive one or more files over FTPS filtering by wildcard pattern

This sample will receive one or more files over FTPS filtering by a wildcard pattern.

**Step 1 -- 5**

Same as in the previous example.

**Step 6**

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.

image alt text

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-”.

**Step 7**

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:

image alt text

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.

**Step 8**

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.