# mulesoft FTP Connector - Full Documentation --- product: FTP Connector version: 2.0 is-latest-version: true --- # Configuring a Proxy for FTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for FTP (FTP Connector) enables you to configure an HTTP or HTTPS tunnel proxy. The following example shows how to configure the **Proxy** field: 1. In Studio, select your FTP Connector operation from the canvas. 2. In the configuration screen for the operation, click the plus sign (**+**) next to **Connector configuration** to access the global element configuration fields. 3. On the **General** tab, specify the connection information for the connector. 4. Set **Proxy** to **Https tunnel proxy**. 5. Set **TLS Configuration** to **Edit inline**. 6. For **Trust Store Configuration**, select **Insecure**. 7. Set the following fields: - **Proxy host**: `localhost` - **Proxy port**: `3129` - **Proxy username**: `userprox` - **Proxy host**: `passprox` 8. Click **OK**. ![FTP Connector Global Element Configuration window with Proxy field set to HTTPS tunnel proxy](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-proxy-configuration.png) In the **Configuration XML** tab, the configuration `ftp:https-tunnel-proxy` looks like this: ```xml ``` ## See Also - [FTP Connector Examples](https://docs.mulesoft.com/ftp-connector/latest/ftp-examples) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Connect to an FTP Server Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To configure the global element to connect to an FTP server, follow these steps: 1. Select the name of the connector in the Studio canvas. 2. Select the operation in the Studio canvas. 3. In the configuration screen for the operation, click the plus sign (**+**) next to **Connector configuration** to access the global element configuration fields. 4. On the **General** tab, specify the connection information for the connector. 5. Set **Working Directory** to `${workingDir}`. This is the root of every relative path used with this connector. The value defaults to the remote server. 6. Set **Host** to specify the SFTP server host, for example, `localhost` or `192.168.0.1`. 7. Set **Port** to `${ftpPort}`. 8. Set **Username** to `anonymous` and **Password** to `password`. 9. On the **Advanced** tab, optionally specify the timeout configuration and reconnection strategy. 10. Click **Test Connection** to confirm that Mule can connect with the specified server. 11. Click **OK**. ![FTP Connector Global Element Configuration](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-global-configuration.png) In the **Configuration XML** tab of your Studio canvas, the configuration `ftp:config` looks like this: ```xml ``` ## See Also - [FTP Connector Examples](https://docs.mulesoft.com/ftp-connector/latest/ftp-examples) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Connect to FTP Servers Dynamically Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Many integrations require connecting to different servers based on a specific condition, such as: - Connecting to different invoice storage servers, depending on the branch that sends an invoice. - Connecting to different servers, depending on an integration subject, such as in a multi-tenant use case. To accommodate these use cases, the `config` element supports parameter expressions that evaluate these conditions and connect to the correct server. The following example shows a dynamic multicast application that: - Defines a configuration for the connector in which the `host`, `username`, and `password` are expressions. - Describes a flow, triggered by an **HTTP Listener**, in which content is posted through HTTP. - Uses the File Connector **Read** operation to load a `recipients.csv` file that contains a set of FTP destinations, with columns such as `host`, `user`, and `port`. - Uses a **For Each** component and an FTP **Write** operation to write the contents into each of the FTP destinations. On each **For Each** iteration, the expressions set in the FTP global configuration element resolve to a different value and establish different connections to each of the servers. To test this example, create the Mule application and run it using curl commands: ![FTP Servers Dynamic Connection Flow in Studio Canvas](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp_dynamic_connect_flow.png) ## Create the Mule Application To create the Mule application flow: 1. In the **Mule Palette** view, select **HTTP > Listener**. 2. Drag **HTTP Listener** to the Studio canvas. 3. On the **HTTP Listener** configuration screen, optionally change the value of the **Display Name** field. 4. Set **Path** to `/multitenant`. 5. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of HTTP Listener in the app. 6. On the **General** tab, set the following fields: - **Host**: `All Interfaces [0.0.0.0] (default)` - **Port**: `8081` 7. Click **OK**. 8. Drag a **Set Variable** component to the right of the **HTTP Listener** source. 9. Set **Name** to `content` and **Value** to `#[payload]`. 10. Drag the File Connector **Read** operation to the right of the **Set Variable** component. 11. Set **File Path** to `recipients.csv`. This reads a CSV file that contains a random set of FTP destinations with columns such as `host`, `user`, and `port`. 12. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of File Connector in the app. 13. Accept the default settings and click **OK**. 14. On the **MIME Type** tab of the **Read** operation, for **MIME Type**, select **application/csv**. 15. In Studio, drag a **Transform Message** component to the right of the **Read** operation. 16. In the **Output** section of the component, add the following DataWeave code to map the columns of the CSV file: DataWeave script: ```dataweave %dw 2.0 output application/java --- payload map using (row = $) { host: row.Host, user: row.User, password: row.Password} ``` 17. Drag a **For Each** component to the right of the **Transform Message** component. 18. Drag an FTP **Write** operation into the **For Each** component. On each For Each iteration, the **Write** operation writes the contents into each of the FTP destinations. 19. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of FTP **Write** operation in the app, and set the following fields: - **Host**: `#[payload.host]` - **Username**: `#[payload.username]` - **Password**: `#[payload.password]` 20. Click **OK**. 21. Set **Path** to `demo.txt`. 22. Set the **Content** field to `payload`. 23. Drag a **Set Payload** component to the right of the **For Each** component. 24. Set the **Value** field to `Multicast Ok`. ## Run and Test Your Mule Application After creating your Mule application, run and test it: 1. In Studio, save your Mule app. 2. Click the project name in **Package Explorer** and then click **Run** > **Run As** > **Mule Application**. 3. Open a browser and type `http://0.0.0.0:8081/multitenant`. - Although the information posted through the HTTP Listener source is written to each FTP site multiple times, the repeatable streams feature prevents the overhead from consuming the stream multiple times. - The For Each component automatically goes through each line of the CSV file without needing to first transform it into a Java structure. When reading or listing files, you might be interested in the file’s metadata (for example, the file name, full path, size, timestamp). The connector uses the Mule message attributes to access this information. ## XML for Connecting to FTP Servers Dynamically Paste this code into the **Configuration XML** tab in your Studio canvas to quickly load the flow for this example into your Mule app: ```xml ``` ## See Also - [FTP Connector Examples](https://docs.mulesoft.com/ftp-connector/latest/ftp-examples) - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Copy and Move Files with the FTP Connector Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for FTP (FTP Connector) provides **Copy** and **Move** operations that enable you to copy and move files or directories on demand. While SFTP has a native concept of copying and moving, FTP does not. FTP Connector simulates these operations by downloading file content and writing it to a new location, using concurrent streams that start writing and reading at the same time. Because these operations create significant network overhead, use them wisely. ## Configure the Copy Operation in Studio To add and configure the **Copy** operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `ftp` and select the **Copy** operation. 2. Drag the **Copy** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the connection information and click **OK**. 5. Set **Source path** to the path of the file to copy, for example, `source.txt`. 6. Set **Target path** to the directory path into which to copy the file, for example, `backup`. 7. Set **Rename to** to rename the file as part of the operation, for example, `renamed.txt`. This field must be a filename, not a path. If this attribute is not provided, the original filename is used. ![Copy operation configuration in Studio](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-copy-operation.png) In the Configuration XML editor, the `` configuration looks like this: ```xml ``` ## Configure the Move Operation in Studio To add and configure the **Move** operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `ftp` and select the **Move** operation. 2. Drag the **Move** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the connection information and click **OK**. 5. Set **Source path** to the path of the file to move, for example, `source.txt`. 6. Set **Target path** to the directory path into which to move the file, for example, `backup`. 7. Set **Rename to** to rename the file as part of the operation, for example, `renamed.txt`. This field must be a filename, not a path. If this attribute is not provided, the original filename is used. ![Move operation configuration in Studio](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-move-operation.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## See Also - [FTP Connector Examples](https://docs.mulesoft.com/ftp-connector/latest/ftp-examples#write) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Create a Directory Using FTP Connector Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for FTP (FTP Connector) provides a **Create directory** operation that enables you to create a directory of a given name. If the reason for creating the directory is to immediately write, copy, or move content to the directory, then use the **Write**, **Copy**, or **Move** operations with the **Create parent directories** field set to **TRUE**. ## Configure the Create Directory Operation in Studio To add and configure the **Create directory** operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `ftp` and select the **Create directory** operation. 2. Drag the **Create directory** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the connection information and click **OK**. 5. Set **Directory path** to the new directory’s path name, for example, `~/newFolder`. ![Create directory operation configuration in Studio](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-create-directory-operation.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## See Also - [FTP Connector Examples](https://docs.mulesoft.com/ftp-connector/latest/ftp-examples) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Disable Pooling in the FTP Connector Configuration > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Disable connection pooling in the Anypoint Connector for FTP (FTP Connector) configuration to ensure no connection is active if there is nothing to transfer. 1. In Studio, navigate to the **Global Elements** tab. 2. Click **Create**. 3. Type `ftp`. 4. Select **FTP Connector**. 5. Click **OK**. 6. In the **Global Elements** properties tab, click the **Advanced** tab. 7. Set **Pooling profile** to **Edit inline**. 8. Set the values of **Max active**, **Max idle**, and **Max wait** to `0` to ensure that no connection is active if there is nothing to transfer. ## See Also - [FTP Connector Examples](https://docs.mulesoft.com/ftp-connector/latest/ftp-examples) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # FTP Connector 2.0 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Support Category: [Select](https://www.salesforce.com/en-us/wp-content/uploads/sites/4/documents/legal/Agreements/versioning-back-support-policy.pdf) Anypoint Connector for FTP (FTP Connector) provides access to files and folders on an FTP server. FTP connector operations manage file transfers by using File Transfer Protocol (FTP). The connector’s main features include: - The ability to read files or fully list directory contents on demand. - Support for common FTP operations such as creating directories and copying, moving, renaming, and deleting files. - Support for locking files. - File matching functionality. - A design that is consistent with the File and FTP Connectors. The same set of operations is available using these two connectors, and they behave similarly. > [!NOTE] FTP Connector doesn’t support z/OS MVS Datasets. ## Representation of File Attributes Mule 4 provides a message structure of a payload and attributes in which the data moves around, making that payload a file content. The attributes provide an object that contains metadata on the payload and information such as the file’s name, path, size, and timestamps. For FTP Connector and SFTP Connector, these attributes are known as _file attributes_. Messages comprise _file content_ (a payload) and _file attributes_ (metadata about the payload, such the file’s name, path, size, and timestamps. The file attributes also describe the format in which a payload is represented by including a file’s encoding and MIME type. ## Before You Begin To use this connector, you must be familiar with: - Anypoint Connectors - Mule runtime engine (Mule) - Elements and global elements in a Mule flow - Creating a Mule app using Anypoint Studio or Anypoint Code Builder Before creating an app, you must have access to Anypoint Platform and Anypoint Studio. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Exchange to Discover Connectors, Templates, and Examples](https://docs.mulesoft.com/connectors/introduction/intro-use-exchange) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # FTP Connector 2.0 Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Support Category: [Select](https://www.salesforce.com/en-us/wp-content/uploads/sites/4/documents/legal/Agreements/versioning-back-support-policy.pdf) FTP Connector connects to the specified FTP server. ## Configurations --- ### Default Configuration #### Parameters
NameTypeDescriptionDefault ValueRequired

Name

String

The name for this configuration. Connectors reference the configuration with this name.

x

Connection

The connection types to provide to this configuration.

x

Default write encoding (DEPRECATED)

String

This parameter is deprecated and is ignored.

Time Between Size Check

Number

When enabled, Mule performs two size checks, waiting the specified time between calls. If both checks return the same value, the file is ready to be read. This allows a file write to complete before the file is processed. This attribute works in tandem with *Time between size check unit*. If no value is provided, the check is not performed.

Time Between Size Check Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A Time unit that qualifies the Time between size check attribute. Defaults to MILLISECONDS.

MILLISECONDS

Expiration Policy

Configures the minimum amount of time that a dynamic configuration instance can remain idle before the runtime considers it eligible for expiration. This does not mean that the platform expires the instance at the exact moment that it becomes eligible. The runtime purges the instances when as appropriate.

#### Connection Types ##### FTP Connection Connects to an FTP server. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Working Directory

String

The directory designated as the root of every relative path used with this connector. If not provided, it defaults to the remote server default.

Proxy

Enables you to set HTTP or HTTPS tunnel proxy.

Transfer Mode

Enumeration, one of:

  • BINARY

  • ASCII

The transfer mode to use. Currently, BINARY (default) and ASCII are supported.

BINARY

Passive

Boolean

Whether to use passive mode. Set to false to switch to active mode.

true

Enable Remote Verification

Boolean

Enable or disable verification that the remote host taking part of a data connection is the same as the host to which the control connection is attached.

true

Control Encoding

String

Set the control encoding to use in the control channel with the remote server. This does NOT set the encoding for the content of the files to be transferred. Known control encodings include: ISO-8859-1 and UTF-8

ISO-8859-1

Connection Timeout

Number

A scalar value representing the amount of time to wait before a connection attempt times out. This attribute works in tandem with Connection timeout unit.

10

Connection Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A Time unit that qualifies the Connection timeout attribute.

SECONDS

Response Timeout

Number

A scalar value representing the amount of time to wait before a request for data times out. This attribute works in tandem with Response timeout unit.

10

Response Timeout Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A Time unit that qualifies the Response timeout unit attribute.

SECONDS

Host

String

The FTP server host, such as www.mulesoft.com, localhost, or 192.168.0.1, and so on.

x

Port

Number

The port number of the FTP server to which to connect.

21

Username

String

Username for the FTP Server. Required if the server is authenticated.

Password

String

Password for the FTP Server. Required if the server is authenticated.

Reconnection

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Pooling Profile

Characteristics of the connection pool.

## Operations - [Copy](#copy) - [Create Directory](#createDirectory) - [Delete](#delete) - [List](#list) - [Move](#move) - [Read](#read) - [Rename](#rename) - [Write](#write) ### Associated Sources - [On New or Updated File](#listener) ### Copy `` Copies the file or directory specified in **Source Path** into the **Target Path**. The source path can be either a file or a directory. If it points to a directory, then it is copied recursively. If the target path doesn’t exist, and neither does its parent, then a parent folder is created if **Create parent directories** is set to `true`. If **Create parent directories** is set to `false`, then an `FTP:ILLEGAL_PATH` error is thrown. If **Overwrite** is set to `true` and the target file already exists, then the target file is overwritten. Otherwise, an `FTP:FILE_ALREADY_EXISTS` error is thrown. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Source Path

String

The path to the file to be copied.

x

Target Path

String

The target directory where the file is going to be copied.

x

Create Parent Directories

Boolean

Whether or not to attempt creating any parent directories that don’t exist.

true

Overwrite

Boolean

Whether or not to overwrite the file if the target destination already exists.

false

Rename To

String

The new name for the copied file. If not provided, original file name is kept.

Reconnection Strategy

A retry strategy in case of connectivity errors.

### For Configurations - [Default Configuration](#config) #### Throws - FTP:FILE\_ALREADY\_EXISTS - FTP:RETRY\_EXHAUSTED - FTP:ILLEGAL\_PATH - FTP:CONNECTIVITY ### Create Directory `` Creates a new directory on **Directory path**. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Directory Path

String

The name for the new directory.

x

Reconnection Strategy

A retry strategy in case of connectivity errors.

### For Configurations - [Default Configuration](#config) #### Throws - FTP:FILE\_ALREADY\_EXISTS - FTP:RETRY\_EXHAUSTED - FTP:ILLEGAL\_PATH - FTP:ACCESS\_DENIED - FTP:CONNECTIVITY ### Delete `` Deletes the file that is pointed to by the path, provided the file isn’t locked. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Path

String

The path to the file to delete.

x

Reconnection Strategy

A retry strategy in case of connectivity errors.

### For Configurations - [Default Configuration](#config) #### Throws - FTP:RETRY\_EXHAUSTED - FTP:ILLEGAL\_PATH - FTP:ACCESS\_DENIED - FTP:CONNECTIVITY ### List `` Lists all the files in the **Directory path** that match the given matcher. If the listing encounters a directory, the output list will include its file path, depending on the value of the recursive parameter. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Directory Path

String

The path to the directory to list.

x

Recursive

Boolean

Whether to include the contents of subdirectories.

false

File Matching Rules

A matcher used to filter the output list.

Streaming Strategy

Configure to use repeatable streams.

Target Variable

String

The name of a variable to store the operation’s output.

Target Value

String

An expression to evaluate against the operation’s output and then store the expression’s outcome in the target variable.

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors.

#### Output

Type

Array of Message of payload and [Ftp File Attributes] attributes.

### For Configurations - [Default Configuration](#config) #### Throws - FTP:ILLEGAL\_PATH - FTP:ACCESS\_DENIED ### Move `` Moves the file or directory from the **Source Path** into the **Target Path**. The source path can be either a file or a directory. If it points to a directory, then it will be moved recursively. If the target path doesn’t exist, and neither does its parent, then a parent folder is created if **Create parent directories** is set to `true`. If **Create parent directories** is set to `false`, then an `FTP:ILLEGAL_PATH` error is thrown. If the target file already exists, then it will be overwritten if **Overwrite** is set to `true`. If **Overwrite** is set to `false`, an `FTP:FILE_ALREADY_EXISTS` error will be thrown. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Source Path

String

The path to the file to be copied.

x

Target Path

String

The target directory.

x

Create Parent Directories

Boolean

Whether or not to attempt creating any parent directories that don’t exist.

true

Overwrite

Boolean

Whether or not to overwrite the file if the target destination already exists.

false

Rename To

String

The new name for the moved file. If not provided, the original file name is kept.

Reconnection Strategy

A retry strategy in case of connectivity errors.

### For Configurations - [Default Configuration](#config) #### Throws - FTP:FILE\_ALREADY\_EXISTS - FTP:RETRY\_EXHAUSTED - FTP:ILLEGAL\_PATH - FTP:CONNECTIVITY ### Read `` Obtains the content and metadata of a file at a specified path. The operation itself returns a Message with a payload that is an input stream with the file’s content, and the metadata is represented as an `FtpFileAttributes` object that’s placed as the message’s `Message#getAttributes()` attributes. If the lock parameter is set to `true`, then a file system-level lock is placed on the file until the input stream this operation returns is closed or fully consumed. Because the lock is actually provided by the host file system, its behavior might change depending on the mounted drive and the operation system on which Mule is running. Take that into consideration before relying on this lock. This method also makes a best effort to determine the MIME type of the file being read by using the file’s extension to make an educated guess. You can also use the output **Encoding** and output **MIME Type** optional parameters to force the encoding and MIME type. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

File Path

String

The path to the file to be read.

x

Lock

Boolean

Whether or not to lock the file.

false

Time Between Size Check

Number

Time Between Size Check Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

Output Mime Type

String

The MIME type of the payload that this operation outputs.

Output Encoding

String

The encoding of the payload that this operation outputs.

Streaming Strategy

Configure to use repeatable streams.

Target Variable

String

The name of a variable to store the operation’s output.

Target Value

String

An expression to evaluate against the operation’s output and store the expression outcome in the target variable.

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors.

#### Output

Type

Binary

Attributes Type

### For Configurations - [Default Configuration](#config) #### Throws - FTP:FILE\_LOCK - FTP:RETRY\_EXHAUSTED - FTP:ILLEGAL\_PATH - FTP:ACCESS\_DENIED - FTP:CONNECTIVITY ### Rename `` Renames the file to which the path points to the value provided in the New Name parameter. This argument should not contain any path separator, or an FTP:ILLEGAL\_PATH error will be thrown. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Path

String

The path to the file to be renamed.

x

New Name

String

The file’s new name.

x

Overwrite

Boolean

Whether or not to overwrite the file if the target destination already exists.

false

Reconnection Strategy

A retry strategy in case of connectivity errors.

### For Configurations - [Default Configuration](#config) #### Throws - FTP:FILE\_ALREADY\_EXISTS - FTP:RETRY\_EXHAUSTED - FTP:ILLEGAL\_PATH - FTP:ACCESS\_DENIED - FTP:CONNECTIVITY ### Write `` Writes the content into the file the path points to. If the directory to which the file is attempting to be written doesn’t exist, then the operation will either throw an FTP:ILLEGAL\_PATH error, or create a new folder, depending on the value of **Create parent directories**. If the file already exists, then the behavior depends on the supplied mode. This operation also supports locking depending on the value of the lock argument, and follows the same rules and considerations as described in the read operation. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Path

String

The path of the file to be written to.

x

Content

Binary

The content to be written into the file. Defaults to the current Message payload.

#[payload]

Encoding (DEPRECATED)

String

When content is a String, this attribute specifies the encoding to use when writing. If not set, then it defaults to FileConnectorConfig#getDefaultWriteEncoding().

Create Parent Directories

Boolean

Whether or not to attempt creating any parent directories that don’t exist.

true

Lock

Boolean

Whether or not to lock the file.

false

Write Mode

Enumeration, one of:

  • OVERWRITE

  • APPEND

  • CREATE_NEW

A file Write Mode.

OVERWRITE

Reconnection Strategy

A retry strategy in case of connectivity errors.

### For Configurations - [Default Configuration](#config) #### Throws - FTP:FILE\_LOCK - FTP:ILLEGAL\_CONTENT - FTP:FILE\_ALREADY\_EXISTS - FTP:RETRY\_EXHAUSTED - FTP:ILLEGAL\_PATH - FTP:ACCESS\_DENIED - FTP:CONNECTIVITY ## Sources ### On New or Updated File `` Polls a directory and looks for files that have been created in it. One message is generated for each file that is found. The key part of this functionality is how to determine that a file is actually new. There are three strategies for that: - Set the **Auto delete** parameter to `true` to delete each file after it is processed, which causes all files obtained in the next poll to be necessarily new. - Set the **Move to directory** parameter to move each file to a different directory after it is processed, which achieves the same effect as **Auto delete** but without losing the file. - Use **Watermark enabled** to pick only files that have been created or updated after the last poll was executed. You can also use a matcher for additional filtering of files. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Directory

String

The directory that contains polled files.

Recursive

Boolean

Whether or not to also poll files contained in subdirectories.

true

Matcher

A matcher used to filter events on files that do not meet the matcher’s criteria.

Watermark Enabled

Boolean

Controls whether or not to do watermarking, and if so, if the watermark should consider the file’s modification or creation timestamps.

false

Time Between Size Check

Number

Wait time (in milliseconds) between size checks to determine if a file is ready to be read. This allows a file write to complete before processing. You can disable this feature by omitting a value. When enabled, Mule performs two size checks, waiting the specified time between calls. If both checks return the same value, the file is ready to be read.

Time Between Size Check Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A Time unit that qualifies the Time between size check attribute.

Output Mime Type

String

The MIME type of the payload that this operation outputs.

Output Encoding

String

The encoding of the payload that this operation outputs.

Primary Node Only

Boolean

Whether this source should be executed only on the primary node when running in a Cluster.

Scheduling Strategy

scheduling-strategy

Configures the scheduler that triggers the polling.

x

Streaming Strategy

Configure to use repeatable streams.

Redelivery Policy

Defines a policy for processing the redelivery of the same message.

Reconnection Strategy

A retry strategy in case of connectivity errors.

Auto Delete

Boolean

Whether or not each file should be deleted after processing.

false

Move To Directory

String

If provided, each processed file will be moved to a directory pointed to by this path.

Rename To

String

This parameter works in tandem with Move to directory. Use this parameter to enter the name under which the file should be moved. Do not set this parameter if Move to directory hasn’t been set as well.

Apply Post Action When Failed

Boolean

Whether any of the post actions (autoDelete and moveToDirectory) should also be applied in case the file failed to be processed. If set to false, no failed files will be moved or deleted.

true

Overwrite

Boolean

Enables you to overwrite the target file when the destination file has the same name.

false

#### Output

Type

Binary

Attributes Type

### For Configurations - [Default Configuration](#config) ## Types ### Reconnection
FieldTypeDescriptionDefault ValueRequired

Fails Deployment

Boolean

When the application is deployed, a connectivity test is performed on all connectors. If set to true, deployment fails if the test doesn’t pass after exhausting the associated reconnection strategy.

Reconnection Strategy

The reconnection strategy to use.

### Reconnect
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

How often in milliseconds to reconnect.

Count

Number

How many reconnection attempts to make.

blocking

Boolean

If false, the reconnection strategy runs in a separate, non-blocking thread. Note: This field is configurable only in XML.

true

### Reconnect Forever
FieldTypeDescriptionDefault ValueRequired

Frequency

Number

How often in milliseconds to reconnect.

blocking

Boolean

If false, the reconnection strategy runs in a separate, non-blocking thread. Note: This field is configurable only in XML.

true

### Pooling Profile The natural behavior of the connection pooling mechanism is to avoid creating connections all the time. The mechanism does not actually close managed connections; instead, the pool retrieves released connections and keeps them active for reuse when a user needs them.
FieldTypeDescriptionDefault ValueRequired

Max Active

Number

Controls the maximum number of connections that can be borrowed from a session at one time. When set to a negative value, there is no limit to the number of components that can be active at one time. When maxActive is exceeded, the pool is said to be exhausted.

Max Idle

Number

Controls the maximum number of connections that can sit idle in the pool at any time. When set to a negative value, there is no limit to the number of connections that can be idle at one time.

Max Wait

Number

Specifies the number of milliseconds to wait for a pooled component to become available when the pool is exhausted and the Exhausted action is set to WHEN_EXHAUSTED_WAIT.

Min Eviction Millis

Number

Determines the minimum amount of time an object can sit idle in the pool before it is eligible for eviction. When non-positive, no objects will be evicted from the pool due to idle time alone.

Eviction Check Interval Millis

Number

Specifies the number of milliseconds between runs of the object evictor. When non-positive, no object evictor is executed.

Exhausted Action

Enumeration, one of:

  • WHEN_EXHAUSTED_GROW

  • WHEN_EXHAUSTED_WAIT

  • WHEN_EXHAUSTED_FAIL

Specifies the behavior of the Mule component pool when the pool is exhausted. Possible values are:

  • WHEN_EXHAUSTED_FAIL
    Throws a NoSuchElementException.

  • WHEN_EXHAUSTED_WAIT
    Blocks by invoking Object.wait(long) until a new or idle object is available.

  • WHEN_EXHAUSTED_GROW
    Creates a new Mule instance and returns it, essentially making Max active meaningless.

If a positive Max wait value is supplied, it will block for that many milliseconds at most, after which a NoSuchElementException will be thrown. If maxThreadWait is a negative value, it will block indefinitely.

Initialisation Policy

Enumeration, one of:

  • INITIALISE_NONE

  • INITIALISE_ONE

  • INITIALISE_ALL

Determines how components in a pool should be initialized. The possible values are:

  • INITIALISE_NONE
    Will not load any components into the pool on startup.

  • INITIALISE_ONE
    Will load one initial component into the pool on startup.

  • INITIALISE_ALL
    Will load all components in the pool on startup.

### Expiration Policy
FieldTypeDescriptionDefault ValueRequired

Max Idle Time

Number

A scalar time value for the maximum amount of time a dynamic configuration instance should be allowed to be idle before it’s considered eligible for expiration.

Time Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A time unit that qualifies the maxIdleTime attribute.

### Ftp File Attributes
FieldTypeDescriptionDefault ValueRequired

Timestamp

DateTime

Name

String

x

Size

Number

x

Regular File

Boolean

false

Directory

Boolean

false

Symbolic Link

Boolean

false

Path

String

x

File Name

String

x

### Matcher
FieldTypeDescriptionDefault ValueRequired

Timestamp Since

DateTime

Files created before this date are rejected. If no creation date is available, the file will be processed. Any timezone specification in this value is ignored and the Mule server’s time zone is used instead.

Timestamp Until

DateTime

Files created after this date are rejected. If no creation date is available, the file will be processed. Any timezone specification in this value is ignored and the Mule server’s time zone is used instead.

Not Updated In The Last

Number

Minimum time that should pass since a file was updated in order for it to not be rejected. This attribute works in tandem with #timeUnit.

Updated In The Last

Number

Maximum time that should pass since a file was updated in order to not be rejected. This attribute works in tandem with #timeUnit.

Time Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A #notUpdatedInTheLast attributes.

Defaults to SECONDS

SECONDS

Case Sensitive

Boolean

Enables you to configure an external file system matcher as case sensitive or insensitive.

true

Filename Pattern

String

Path Pattern

String

Directories

Enumeration, one of:

  • REQUIRE

  • INCLUDE

  • EXCLUDE

INCLUDE

Regular Files

Enumeration, one of:

  • REQUIRE

  • INCLUDE

  • EXCLUDE

INCLUDE

Sym Links

Enumeration, one of:

  • REQUIRE

  • INCLUDE

  • EXCLUDE

INCLUDE

Min Size

Number

Max Size

Number

### Repeatable In Memory Stream
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

The amount of memory to allocate to consume the stream and provide random access to it. If the stream contains more data than can be fit into this buffer, then the buffer expands according to the Buffer size increment attribute, with an upper limit of maxInMemorySize.

Buffer Size Increment

Number

This is by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer should not expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised when the buffer gets full.

Max Buffer Size

Number

The maximum amount of memory to use. If more than that is used then a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised. A value lower than, or equal to, zero means no limit.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

The unit in which all these attributes are expressed.

### Repeatable File Store Stream
FieldTypeDescriptionDefault ValueRequired

In Memory Size

Number

Defines the maximum memory that the stream should use to keep data in memory. If more than that is consumed then it will start to buffer the content on disk.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

The unit in which maxInMemorySize is expressed.

### Redelivery Policy
FieldTypeDescriptionDefault ValueRequired

Max Redelivery Count

Number

The maximum number of times a message can be redelivered and processed unsuccessfully before triggering a process-failed-message.

Use Secure Hash

Boolean

Whether to use a secure hash algorithm to identify a redelivered message.

Message Digest Algorithm

String

The secure hashing algorithm to use. If not set, the default is SHA-256.

SHA-256

Id Expression

String

Defines one or more expressions to use to determine when a message has been redelivered. This property may only be set if Use secure hash is false.

Object Store

Object Store

The object store where the redelivery counter for each message is going to be stored.

### Repeatable In Memory Iterable
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

The amount of instances that is initially be allowed to be kept in memory to consume the stream and provide random access to it. If the stream contains more data than can fit into this buffer, then the buffer expands according to the Buffer size increment attribute, with an upper limit of maxInMemorySize. Default value is 100 instances.

100

Buffer Size Increment

Number

This is by how much the buffer size expands if it exceeds its initial size. Setting a value of zero or lower means that the buffer should not expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised when the buffer gets full. Default value is 100 instances.

100

Max Buffer Size

Number

The maximum amount of memory to use. If more than that is used then a STREAM_MAXIMUM_SIZE_EXCEEDED error is raised. A value lower than, or equal to, zero means no limit.

### Repeatable File Store Iterable
FieldTypeDescriptionDefault ValueRequired

In Memory Objects

Number

The maximum amount of instances that will be kept in memory. If more than that is required, then it will start to buffer the content on disk.

Buffer Unit

Enumeration, one of:

  • BYTE

  • KB

  • MB

  • GB

The unit in which maxInMemorySize is expressed

### HTTP Tunnel Proxy
FieldTypeDescriptionDefault ValueRequired

Host

String

The FTP proxy server host, such as www.mulesoft.com, localhost, or 192.168.0.1, etc.

Port

Number

Port number of the FTP proxy server to connect.

Username

String

Username for the FTP proxy server. Required if the proxy server is authenticated.

Password

String

Password for the FTP proxy server. Required if the proxy server is authenticated.

### HTTP Tunnel Proxy
FieldTypeDescriptionDefault ValueRequired

Tls Context Factory

Host

String

The FTP proxy server host, such as www.mulesoft.com, localhost, or 192.168.0.1, etc.

Port

Number

Port number of the FTP proxy server to connect.

Username

String

Username for the FTP proxy server. Required if the proxy server is authenticated.

Password

String

Password for the FTP proxy server. Required if the Proxy server is authenticated.

### Tls
FieldTypeDescriptionDefault ValueRequired

Enabled Protocols

String

A comma separated list of protocols enabled for this context.

Enabled Cipher Suites

String

A comma separated list of cipher suites enabled for this context.

Trust Store

Key Store

Revocation Check

### Truststore Configures the TLS truststore.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the truststore. Mule resolves the path relative to the current classpath and file system.

Password

String

Password used to protect the truststore.

Type

String

Type of truststore.

Algorithm

String

Encryption algorithm that the truststore uses.

Insecure

Boolean

If true, Mule stops performing certificate validations. Setting this to true can make connections vulnerable to attacks.

### Key Store Configures the keystore for the TLS protocol. The keystore you generate contains a private key and a public certificate.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the keystore. Mule resolves the path relative to the current classpath and file system, if possible.

Type

String

Type of keystore used.

Alias

String

Alias of the key to use when the keystore contains multiple private keys. By default, Mule uses the first key in the file.

Key Password

String

Password used to protect the private key.

Password

String

Password used to protect the key store.

Algorithm

String

Encryption algorithm that the keystore uses.

### Standard Revocation Check Configures standard revocation checks for TLS certificates.
FieldTypeDescriptionDefault ValueRequired

Only End Entities

Boolean

Verify the last element of the certificate chain only.

Prefer Crls

Boolean

Try CRL instead of OCSP first.

No Fallback

Boolean

Do not use the secondary checking method, which is the method not specified in the Prefer Crls field.

Soft Fail

Boolean

Avoid verification failure when the revocation server cannot be reached or is busy.

### Custom Ocsp Responder Configures a custom OCSP responder for certification revocation checks.
FieldTypeDescriptionDefault ValueRequired

Url

String

URL of the OCSP responder.

Cert Alias

String

Alias of the signing certicate for the OCSP response. If specified, the alias must be in the truststore.

### Crl File Specifies the location of the certification revocation list (CRL) file.
FieldTypeDescriptionDefault ValueRequired

Path

String

Path to the CRL file.

## See Also - [FTP Connector Release Notes](https://docs.mulesoft.com/release-notes/connector/connector-ftp) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # FTP Connector Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To fully benefit from using Anypoint Connector for FTP (FTP Connector), see the following examples of configuring the connector operations: - [Read a File](https://docs.mulesoft.com/ftp-connector/latest/ftp-read) Configure the **Read** operation to read a file at any point in the flow. - [Write a File](https://docs.mulesoft.com/ftp-connector/latest/ftp-write) Configure the **Write** operation to write content into the given path on demand. - [List Files](https://docs.mulesoft.com/ftp-connector/latest/ftp-list) Configure the **List** operation to list the files and folders in the configured directory path. - [Copy and Move Files](https://docs.mulesoft.com/ftp-connector/latest/ftp-copy-move) Configure the **Copy** and **Move** operations to copy or move files or directories on demand. - [Trigger a Flow for a Newly Created or Updated File](https://docs.mulesoft.com/ftp-connector/latest/ftp-on-new-file) Configure the **On New or Updated File** source to trigger a flow for a new created or modified file. - [Connect to an FTP Server](https://docs.mulesoft.com/ftp-connector/latest/ftp-connection) Configure the **FTP Connector** global configuration element to connect to an FTP server. - [Connect to FTP Servers Dynamically](https://docs.mulesoft.com/ftp-connector/latest/ftp-dynamic-connection) Configure the **FTP Connector** to connect dynamically to multiple servers. - [Configure a Proxy for FTP Connector](https://docs.mulesoft.com/ftp-connector/latest/ftp-connector-proxy) Configure the **Proxy** field to either HTTP or HTTP tunnel proxy. - [Disable Pooling](https://docs.mulesoft.com/ftp-connector/latest/ftp-pooling) Disable Pooling in the FTP Connector Configuration ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # FTP Connector XML and Maven Support > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Although you can manually code a Mule app in XML, it is more efficient to use Anypoint Studio. If you manually code a Mule runtime engine (Mule) app in XML, either from the Anypoint Studio XML editor or from a text editor, you can get access to the connector in your app by adding reference statements to both your XML Mule flow and the Apache Maven `pom.xml` file. When you add the connector in Studio, Studio automatically populates the XML code with the connector’s namespace and schema location. It also adds a dependency to the `pom.xml` file. ## Add a Namespace for the Connector Paste the following code inside the `` tag of the header of your configuration XML: ```xml http://www.mulesoft.org/schema/mule/ftp http://www.mulesoft.org/schema/mule/ftp/current/mule-ftp.xsd ``` This example shows how the namespace statements are placed in the `` XML block: ```xml ``` ## Add a POM File Dependency The Apache Maven `pom.xml` file generated by Anypoint Studio contains dependencies for a Mule app. If you code a Mule app manually, include this XML snippet in your `pom.xml` file to enable access to this connector: ```xml org.mule.connectors mule-ftp-connector x.x.x mule-plugin ``` Replace `x.x.x` with the version that corresponds to the connector you are using. To obtain the most up-to-date `pom.xml` file information: 1. Go to [Anypoint Exchange](https://www.mulesoft.com/exchange/). 2. In Exchange, click **Login** and supply your Anypoint Platform username and password. 3. In Exchange, search for `ftp`. 4. Select the connector. 5. Click **Dependency Snippets** near the upper right of the screen. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # List Files Using the FTP Connector Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for FTP (FTP Connector) provides a **List** operation that returns a list of messages representing files or folders in the directory path: - The path you define in the **Directory path** field can be absolute, or it can be relative to a working directory. - By default, the operation does not read or list files or folders within any subfolders of the directory path. - To list files or folders within any subfolders, set the **Recursive** field to **TRUE**. ## Configure the List Operation in Studio To add and configure the **List** operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `ftp` and select the **List** operation. 2. Drag the **List** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the connection information and click **OK**. 5. In the **General** tab, set **Directory path** to `~/dropFolder` to set the path of the file to list. ![List operation configuration in Studio](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-list-operation-1.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` The following XML example lists the folder contents of messages in the directory path without the subfolder contents. Note that the path can be absolute, or it can be relative to a working directory set in the File configuration. The **For Each** and **Choice** components manage each directory in the list differently from the way they manage each file: ```xml ``` ## Poll a Directory Because Mule 4 doesn’t have a polling message source, you can combine a **Scheduler** source with the SFTP **List** operation to poll a directory to look for new files to process. In the following poll directory example, a flow lists the contents of a folder once per second. The flow then processes the files one by one, deleting each file after it is processed because there is a **Delete** operation in the **For Each** component. ```xml ``` ## Match Filter When listing files, use the **File Matching Rules** field, which accepts files that match the specified criteria. This field defines the possible attributes to either accept or reject a file. These attributes are optional and ignored if you do not provide values for them. Use an `AND` operator to combine individual attributes. To configure the field in Studio, set the **File Matching Rules** field to **Edit inline** and complete the desired attributes: - **Timestamp since** Files created before this date are rejected. Any timezone specification in this value is ignored and the Mule server’s time zone is used instead. - **Timestamp until** Files created after this date are rejected. Any timezone specification in this value is ignored and the Mule server’s time zone is used instead. - **Not updated in the last** Minimum time that should pass since a file was last updated to not be rejected. This attribute works in tandem with **Time unit**. - **Updated in the last** Maximum time that should pass from when a file was last updated to not be rejected. This attribute works in tandem with **Time unit**. - **Time unit** A **Not updated in the last** attributes. Defaults to `MILLISECONDS`. - **Filename pattern** Similar to the current filename pattern filter but more powerful. Glob expressions (default) and regex are supported. You can select which one to use by setting a prefix, for example, `glob:*.{java, js}` or `regex:[0-9]test.csv`. - **Path pattern** Same as **Filename pattern** but applies over the entire file path rather than just a filename. - **Directories** Match only if the file is a directory. - **Regular files** Match only if the file is a regular file. - **Sym links**\` Match only if the file is a symbolic link. - **Min size** Inclusive lower boundary for the file size, expressed in bytes. - **Max size** Inclusive upper boundary for the file size, expressed in bytes. The following screenshot shows the **File Matching Rules** configuration in Studio: ![File Matching Rules field configuration](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-list-operation-2.png) Figure 1. File Matching Rules field configuration In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ### External File System Matcher FTP Connector enables you to use an external file system matcher. Configure the matcher as case sensitive or insensitive in the **Case sensitive** field. In the **Configuration XML** editor, the `caseSensitive` configuration looks like this: ```xml ``` ### Top-Level, Reusable Matcher You can use the file matcher as either a named top-level element that enables reuse or as an inner element that is proprietary to a particular component. The following example shows a top-level reusable matcher: ```xml ... ``` ### Inner Nonreusable Matcher The following example shows an inner nonreusable matcher: ```xml ... ``` ## See Also - [FTP Connector Examples](https://docs.mulesoft.com/ftp-connector/latest/ftp-examples) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Read a File Using the FTP Connector Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for FTP (FTP Connector) provides a **Read** operation that reads a file at any point in the flow. The operation reads the file in the given path and returns a Mule message with the following attributes: - The file’s content as the payload - The file’s metadata in the message attributes - If the file does not exist, you receive an `FTP:ILLEGAL_PATH` error Note that the operation does not read directories. When the file is read from the FTP source folder, the file remains in the same folder until it is manually deleted. The **Read** operation makes use of the repeatable streams functionality. The operation returns a list of messages, where each message represents a file in the list and holds a stream to the file. A stream is repeatable by default. For more information about repeatable streams, refer to the [Streaming in Mule Apps](https://docs.mulesoft.com/mule-runtime/latest/streaming-about) documentation. ## Configure the Read Operation in Studio To add and configure the **Read** operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `ftp` and select the **Read** operation. 2. Drag the **Read** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the connection information and click **OK**. 5. In the **General** tab, set **File Path** to the path of the file to read, for example, `#[path]`. 6. In the **MIME Type** tab, set **MIME Type** to `application/xml` and set **Encoding** to `ISO 10646/Unicode(UTF-8)`. ![Read operation configuration in Studio](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-read-operation.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## MIME Types and Encoding Each connector tries to determine a file’s MIME type from its extension. You can force the MIME type to a different value with the **MIME Type** (`outputMimeType`) parameter. The same process works for encoding. By default, the connector assumes that the default encoding in the Mule runtime matches the MIME type of the file; however, you can set the encoding through the **Encoding** (`outputEncoding`) parameter. ## Why MIME Types Matter DataWeave expressions are embeddable inside operations that generate payloads and other values. Having the correct MIME type set helps DataWeave auto-assign types and also generate the correct outputs. Also, maximizing the use of DataSense’s functionality improves the user experience. ## File Locks File system level locks are not possible in FTP or SFTP, so each operation uses a Mule lock that protects only the file from other flows in the same Mule application. These locks do not protect the file from external processes. However, if the Mule application is running on a cluster, the lock is distributed. The file lock is automatically released when either of the following occur: - The Mule flow that locked the file ends - The file content has been fully read > [!NOTE] If the file is already locked by someone else, the connector cannot unlock it, resulting > in a `FTP:FILE_LOCK` error. ## See Also - [FTP Connector Examples](https://docs.mulesoft.com/ftp-connector/latest/ftp-examples#write) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Trigger a Flow When a New File Is Created or Modified Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connectors for File, FTP, and SFTP provide an **On New or Updated File** operation that polls a directory for files that have been created or updated. A message is generated for each file that is found. The following strategies determine that a file is new: - Set the **Auto delete** field to **True** to delete each file after it is processed, which causes all files obtained in the next poll to be considered new. - Set the **Move to directory** field to move each file to a different directory after it is processed, which achieves the same effect as **Auto delete** but without erasing the file. - Set the **Watermark** field to pick only files that have been created or updated after the last poll was executed. You can also use a matcher for additional filtering of files. To add and configure the **On New or Updated File** operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `ftp` and select the **On New or Updated File** operation. 2. Drag the **On New or Updated File** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. Specify the connection information and click **OK**. 5. Set **Directory** to the directory path on which pooled files are contained, for example, `test-data/in`. 6. Set **Auto delete** to **True**. 7. Select the **Watermark** field to enable watermarking. ![On New or Updated File operation configuration in Studio](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-newupdated-operation.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## See Also - [FTP Connector Examples](https://docs.mulesoft.com/ftp-connector/latest/ftp-examples) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Troubleshooting FTP Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot Anypoint Connector for FTP (FTP Connector), become familiar with the information about troubleshooting Mule application issues. ## Troubleshoot Mule Application Issues Sometimes you are not sure why the application is failing and you require a better understanding of what is going on in the app’s interaction with the FTP server. To resolve this error: - Use the configuration file to increase the logging level on the server side. - Try to replicate the issue using an FTP client, for example, Cyberduck or Filezilla. If the issue also occurs with these clients, then it is likely that the issue is not related to the Mule app. - Get better and more detailed logs on the Mule app side by enabling verbose logging for FTP Connector and for the JSCH driver: 1. Access Anypoint Studio and navigate to the **Package Explorer** view. 2. Open your application’s project name. 3. Open the `src/main/resources` path folder. 4. Open the `log4j2.xml` file inside the folder. 5. If the following line is already in the `log4j2.xml` file, uncomment it to enable it; otherwise, add it: ```xml ``` 6. Add the following argument to your run configuration: \`-M-Djavax.net.debug=ssl,handshake\` - Try to minimize or remove unnecessary DataWeave data transformations (you could even use hard-coded data) to minimize the app’s complexity and determine whether the issue is with the interaction between the app and the FTP server. For additional information about enabling verbose logging for SDK components in your Mule application, see the [troubleshoot SDK components](https://docs.mulesoft.com/mule-sdk/latest/troubleshooting) documentation. ## Understand Common Throws Here is a list of common throw messages and how to interpret them. - FTP:ACCESS\_DENIED An FTP Connector operation attempted to access an FTP server path and performed an action for which the user does not have permission. - FTP:CONNECTIVITY The connection to the FTP server was interrupted. - FTP:FILE\_ALREADY\_EXISTS An attempt was made to create a file with the same location and name as an existing file. - FTP:FILE\_LOCK An attempt to lock a file was unsuccessful. - FTP:ILLEGAL\_CONTENT The **Write** operation received invalid content to write. - FTP:ILLEGAL\_PATH The specified path is invalid because, for example, it does not exist. - FTP:RETRY\_EXHAUSTED Retries of an execution block are exhausted. ## See Also - [FTP Connector Reference](https://docs.mulesoft.com/ftp-connector/latest/ftp-documentation) - [Salesforce Help](https://help.salesforce.com) - [Known Issues](https://help.salesforce.com/s/issues) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Upgrading and Migrating FTP Connector to Version 2.0 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Upgrade Anypoint Connector for FTP (FTP Connector) to version 2.x. ## Supported Upgrade Paths
From VersionTo Version

1.8.x

2.0.x

## Changes in This Release This release contains the following changes: - The `mule-file-commons` module dependency is removed to make FTP Connector a standalone connector. - The **List** operation now returns the file path instead of the file content. - The **List** operation no longer includes the **Time Between Size Check** and **Time Between Size Check Unit** fields because the file content is no longer read. ## Requirements Ensure that you meet these requirements before you perform the upgrade:
Application/ServiceVersion

Mule

4.3.0 and later

## Upgrade Prerequisites Before you perform the upgrade, create a backup of your files, data, and configuration in case you need to restore to the previous version. ## Upgrade Steps Follow these steps to perform the upgrade: 1. In Anypoint Studio, create a Mule project. 2. In **Mule Palette**, click **Search in Exchange**. 3. In **Add Dependencies to Project**, enter `ftp` in the search field. 4. In **Available modules**, select **FTP** and click **Add**. 5. Click **Finish**. 6. Verify that the FTP Connector dependency version is 2.0 in the `pom.xml` file in the Mule project. Studio upgrades the connector automatically. ## Post-Upgrade Steps After you install the latest version of the connector, verify that your error handling is updated to work with the minor changes in error codes in this version of the connector. ## Verify the Upgrade After you install the latest version of the connector, follow these steps to verify the upgrade: 1. In Studio, verify that there are no errors in the **Problems** or **Console** views. 2. Verify that there are no problems in the project `pom.xml` file. 3. Test the connection to verify that the operations work. ## Revert the Upgrade If it is necessary to revert to the previous version of FTP Connector, change the `mule-ftp-connector` dependency version in the project’s `pom.xml` file to the previous version. You must update the project’s `pom.xml` file in Anypoint Studio. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Using Anypoint Studio to Configure FTP Connector 2.0 > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Studio (Studio) editors help you design and update your Mule applications, properties, and configuration files. To add and configure a connector in Studio: 1. [Create a Mule project](#create-mule-project). 2. [Add the connector to your Mule project](#add-connector-to-project). 3. [Configure a source for the connector’s flow](#configure-input-source). 4. [Add a connector operation to the flow](#add-connector-operation). 5. [Configure a global element for the connector](#configure-global-element). When you run the connector, you can view the app log to check for problems in real time, as described in [View the App Log](#view-app-log). If you are new to configuring connectors in Studio, see [Use Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio). If you need additional information about the connector fields after reading this topic, see the [FTP Connector Reference Reference](https://docs.mulesoft.com/ftp-connector/latest/ftp-documentation). ## Create a Mule Project In Studio, create a new Mule project in which to add and configure the connector: 1. In Studio, select **File > New > Mule Project**. 2. Enter a name for your Mule project and click **Finish**. ## Add the Connector to Your Mule Project Add FTP Connector to your Mule project to automatically populate the XML code with the connector’s namespace and schema location and to add the required dependencies to the project’s `pom.xml` file: 1. In the **Mule Palette** view, click **(X) Search in Exchange**. 2. In the **Add Dependencies to Project** window, type `ftp` in the search field. 3. Click **FTP Connector** in **Available modules**. 4. Click **Add**. 5. Click **Finish**. Adding a connector to a Mule project in Studio does not make that connector available to other projects in your Studio workspace. ## Configure a Source A source initiates a flow when a specified condition is met. You can configure one of these sources to use with SFTP Connector: - **On New or Updated File** Initiates a flow by polling a directory for files that have been created or updated and generates a message for each file found. - **HTTP Listener** Initiates a flow each time it receives a request on the configured host and port. - **Scheduler** Initiates a flow when a time-based condition is met. For example, to configure the On New or Updated File source, follow these steps: 1. In the **Mule Palette** view, select **On New or Updated File**. 2. Drag **On New or Updated File** to the Studio canvas. 3. On the **On New or Updated File** configuration screen, optionally change the value of the **Display Name** field. 4. Specify a value for the **Path** field. 5. Click the plus sign (**+**) next to the **Connector configuration** field to configure a global element that can be used by all instances of **On New or Updated File** in the app. 6. On the **General** tab, specify the connection information for the connector. 7. Set **Host** to specify the FTP server host, for example, `localhost` or `192.168.0.1`. 8. Click **Test Connection** to confirm that Mule can connect with the specified server. 9. Click **OK**. 10. On the **On New or Updated File** configuration screen, specify a **Scheduling Strategy** value and optionally complete other fields. ## Add a Connector Operation to the Flow When you add a connector operation to your flow, you immediately define a specific operation for that connector to perform. To add an operation for FTP Connector, follow these steps: 1. In the **Mule Palette** view, select **FTP** and then select the desired operation. 2. Drag the operation onto the Studio canvas and to the right of the source. ![FTP Connector Operations in Mule palette](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-operations.png) ## Configure a Global Element for the Connector When you configure a connector, it’s best to configure a global element that all instances of that connector in the app can use. Configuring a global element requires you to configure the FTP server connection. To configure the global element for FTP Connector, follow these steps: 1. Select the name of the connector in the Studio canvas. 2. Select the operation in the Studio canvas. 3. In the configuration screen for the operation, click the plus sign (**+**) next to the **Connector configuration** field to access the global element configuration fields. 4. On the **General** tab, specify the connection information for the connector: 5. Set the **Working Directory** as the root of every relative path used with this connector. If it’s not provided, the value defaults to the remote server. 6. Set **Host** to specify the FTP server host, for example, `localhost` or `192.168.0.1`. 7. On the **Advanced** tab, optionally specify a timeout configuration and reconnection strategy. 8. Click **Test Connection** to confirm that Mule can connect with the specified server. 9. Click **OK**. ![FTP Connector Global Element Configuration](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-global-configuration.png) In the **Configuration XML** editor, the configuration `ftp:config` looks like this: ```xml ``` ## View the App Log To check for problems, you can view the app log as follows: - If you’re running the app from Anypoint Platform, the output is visible in the Anypoint Studio console window. - If you’re running the app using Mule from the command line, the app log is visible in your OS console. Unless the log file path is customized in the app’s log file (`log4j2.xml`), you can also view the app log in the default location `MULE_HOME/logs/.log`. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Use Studio to Configure a Connector](https://docs.mulesoft.com/connectors/introduction/intro-config-use-studio) - [FTP Connector Reference](https://docs.mulesoft.com/ftp-connector/latest/ftp-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: FTP Connector version: 2.0 is-latest-version: true --- # Write a File Using the FTP Connector Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for FTP (FTP Connector) provides a **Write** operation that writes content into the given path on demand. ## Configure the Write Operation in Studio To add and configure the **Write** operation in Studio, follow these steps: 1. In the **Mule Palette** view, search for `ftp` and select **Write**. 2. Drag the **Write** operation onto the Studio canvas. 3. In the **General** tab of the operation configuration screen, click the plus sign (+) next to **Connector configuration** to access the global element configuration fields. 4. Specify the connection information and click **OK**. 5. In the **General** tab, set **Path** to `output.csv` to set the path of the file to write. By default, the connector writes whatever is in the message payload. ![Write operation configuration in Studio](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-write-config.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## Use Embedded DataWeave Transformations If you place a **Transform Message** component before a **Write** operation, the message payload changes, and that impacts the operation that is placed after the **Write** operation. Therefore, if the payload is in a different format and you need to transform it before writing it, you can place the transformation inside **Content** in the **Write** configuration to generate the content to be written without affecting the message in transit. The following example places the **DataWeave** transformation in **Content**: ![DataWeave transformation in the Content field of the General settings in Studio](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-write-content.png) In the **Configuration XML** editor, the configuration looks like this: ```xml #[%dw 2.0 output application/csv --- payload.customers.email ] ``` ## Write into a Directory The **Write** operation fails by default if you set nonexistent directories in **Path**. Set **Create parent directories** to **True (Default)** to automatically create any missing directories. In the following example, if any of the `a`, `b`, or `c` directories set in **Path** do not exist, the connector creates them: ![Write into the directory General settings in Studio](/mulesoft/current/en-us/ftp-connector/latest/_images/ftp-write-directories.png) In the **Configuration XML** editor, the configuration looks like this: ```xml ``` ## Write to Existing Files When writing content to a file, set **Write Mode** to any of the following modes: - **OVERWRITE (Default)** If the file exists, overwrite it completely. - **APPEND** If the file exists, add its content to the end of an existing file. - **CREATE\_NEW** Create a new file. An error occurs if the file already exists. ## Locks The **Write** operation supports locking similar to the **Read** operation. The main difference is that the lock releases automatically after the **Write** operation finishes. Set **Lock** to either of the following modes: - **TRUE** - **FALSE (Default)** ## See Also - [FTP Connector Examples](https://docs.mulesoft.com/ftp-connector/latest/ftp-examples) - [Salesforce Help](https://help.salesforce.com)