---
schema_version: "1"
id: b2eeb66da42111af1100a32a5c60a12ac0fd0411f983b1cdf6b6bec21079d660
title: Write a File Using the FTP Connector Example
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/ftp-connector/latest/ftp-write.md
canonical_url: https://docs.mulesoft.com/ftp-connector/latest/ftp-write
source_site: docs.mulesoft.com
content_type: documentation
content_hash: a85463ee7751516c9d7c03f4f9ef6eb6e4b52bf77a2b4530334079483977a9a9
description: MuleSoft Documentation Site
release: "2.0"
latest: true
---
---
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 `<ftp:write>` configuration looks like this:

```xml
<ftp:write path="output.csv" />
```

## 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
<ftp:write path="output.csv">
  <ftp:content>#[%dw 2.0
                   output application/csv
                   ---
                   payload.customers.email
                  ]
  </ftp:content>
</ftp:write>
```

## 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
<ftp:write path="a/b/c/myFile.txt" />
```

## 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)
