# mulesoft File Connector - Full Documentation --- product: File Connector version: 1.5 is-latest-version: true --- # Copy and Move Files > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for File (File Connector) provides the **Copy** and **Move** operations that enable you to copy or move files or directories on demand. - **Source path** The directory path name or file name to copy or move. If a file or directory already exists and the **Overwrite** field is set to `false`, the connector throws the message `FILE:FILE_ALREADY_EXISTS`. - **Target path** The directory path name into which to copy or move the file. If a target path doesn’t exist, and neither does its parent, the connector attempts to create the path depending on the value of the **Create parent directories** argument. If **Create parent directories** is `false`, then `FILE:ILLEGAL_PATH` occurs. - **Rename to** Renames the file as part of the operation. Set this field with a file name instead of a path. The connector retains the original file name if you do not configure this field. ## Configure the Copy Operation in Studio 1. In the **Mule Palette** view, search for `file` 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, `Documents/source-folder/file.txt`. 6. Set **Target path** to the directory path into which to copy the file, for example, `Documents/target-folder`. 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/file-connector/latest/_images/file-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/file-connector/latest/_images/file-move-operation.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## See Also - [Salesforce Help](https://help.salesforce.com) --- product: File Connector version: 1.5 is-latest-version: true --- # Create a Directory Using File Connector Example > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for File (File 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 `file` 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/file-connector/latest/_images/file-create-directory-operation.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## See Also - [File Connector Examples](https://docs.mulesoft.com/file-connector/latest/file-examples) - [Salesforce Help](https://help.salesforce.com) --- product: File Connector version: 1.5 is-latest-version: true --- # File Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Anypoint Connector for File (File Connector) manages files and folders on a locally mounted file system. The connector’s main features include: - The ability to read files or fully list directory contents on demand - Support for common file operations such as creating directories, reading, writing, copying, moving, renaming, deleting and listing files - Support for locking files - File matching functionality - A design that is consistent with FTP Connector and SFTP Connector ## Representation of File Attributes Mule 4 provides a message structure of a payload and attributes in which the data moves around, making that payload 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 named _file attributes_. The Mule message specifies the encoding and MIME type, which describe the format in which a payload is represented. The file attributes describe 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) - [File Connector Reference](https://docs.mulesoft.com/file-connector/latest/file-documentation) - [Salesforce Help](https://help.salesforce.com) --- product: File Connector version: 1.5 is-latest-version: true --- # File Connector Examples > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To fully benefit from using Anypoint Connector for File (File Connector), see the following examples of configuring the connector operations: - [Read a File](https://docs.mulesoft.com/file-connector/latest/file-read) Configure the **Read** operation to read a file at any point in the flow. - [Create a Directory](https://docs.mulesoft.com/file-connector/latest/file-create-directory) Configure the **Create directory** operation to create a directory of a given name. - [Write a File](https://docs.mulesoft.com/file-connector/latest/file-write) Configure the **Write** operation to write content into the given path on demand. - [List Files](https://docs.mulesoft.com/file-connector/latest/file-list) Configure the **List** operation to list the files and folders in the configured directory path. - [Copy and Move Files](https://docs.mulesoft.com/file-connector/latest/file-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/file-connector/latest/file-on-new-file) Configure the **On New or Updated File** source to trigger a flow for a new created or modified file. ## See Also - [Introduction to Anypoint Connectors](https://docs.mulesoft.com/connectors/introduction/introduction-to-anypoint-connectors) - [Salesforce Help](https://help.salesforce.com) --- product: File Connector version: 1.5 is-latest-version: true --- # File Connector Reference > For the full documentation index, see: https://docs.mulesoft.com/llms.txt File Connector v1.5 Anypoint Connector for File (File Connector) manipulates file systems mounted on a host operation system. This class serves as both extension definition and configuration. Operations are based on the standard `BaseFileSystemOperations`. Release Notes: [File Connector Release Notes](https://docs.mulesoft.com/release-notes/connector/connector-file) ## 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 that can be provided to this configuration.

x

Default write encoding (DEPRECATED)

String

This parameter is deprecated and is ignored.

Time Between Size Check

Number

Wait time between size checks to determine if a file is ready to read. This allows a file write to complete before processing. If no value is provided, the check is not performed. 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 attribute works in tandem with Time between size check unit.

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.

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 will expire the instance at the exact moment that it becomes eligible. The runtime will actually purge the instances when it sees it fit.

#### Connection Types ##### Local FileSystem Connection A Connection Provider that provides instances of File System from instances of File Connector. ###### Parameters
NameTypeDescriptionDefault ValueRequired

Working Directory

String

The directory to consider the root of every relative path used with this connector. If not provided, it defaults to the value of the user.home system property. If that system property is not set, then the connector fails to initialize.

Reconnection

When an application deploys, 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.

## 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 a `FILE:ILLEGAL_PATH` error is thrown. If **Overwrite** is set to `true` and the target file already exists, then the target file is overwritten. Otherwise, a `FILE: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 to copy the file.

x

Create Parent Directories

Boolean

Whether or not to create parent directories if they 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 - FILE:CONNECTIVITY - FILE:ILLEGAL\_PATH - FILE:FILE\_ALREADY\_EXISTS - FILE:RETRY\_EXHAUSTED ### 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 new directory’s name.

x

Reconnection Strategy

A retry strategy in case of connectivity errors.

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

Configuration

String

The name of the configuration to use.

x

Path

String

The path to the file to be deleted.

x

Reconnection Strategy

A retry strategy in case of connectivity errors.

#### For Configurations - [Default Configuration](#config) #### Throws - FILE:CONNECTIVITY - FILE:ILLEGAL\_PATH - FILE:RETRY\_EXHAUSTED - FILE:ACCESS\_DENIED ### List `` Lists all the files in the **Directory path** that match a matcher. If the listing encounters a directory, the output list includes its contents 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 be listed.

x

Recursive

Boolean

Whether to include the contents of subdirectories.

false

File Matching Rules

A matcher used to filter the output list.

Time Between Size Check

Number

Wait time between size checks to determine if a file is ready to read.

Time Between Size Check Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

Time unit to be used in the wait time between size checks.

Subset

Limit and sort the number of files returned.

Streaming Strategy

Configure if repeatable streams should be used and their behavior.

Target Variable

String

The name of a variable on which the operation’s output is placed.

Target Value

String

An expression to evaluate against the operation’s output and the outcome of that expression is stored in the target variable.

#[payload]

Reconnection Strategy

A retry strategy in case of connectivity errors.

#### Output

Type

Array of Message of [CursorProvider] payload and [Local File Attributes] attributes

#### For Configurations - [Default Configuration](#config) #### Throws - FILE:ILLEGAL\_PATH - FILE: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 a `FILE: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`, a `FILE: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 which don’t exists.

true

Overwrite

Boolean

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

false

Rename To

String

Moved file’s new name. If not provided, original file name is kept.

Reconnection Strategy

A retry strategy in case of connectivity errors.

#### For Configurations - [Default Configuration](#config) #### Throws - FILE:CONNECTIVITY - FILE:ILLEGAL\_PATH - FILE:FILE\_ALREADY\_EXISTS - FILE:RETRY\_EXHAUSTED ### Read `` Obtains the content and metadata of a file at a given path. The operation itself returns a Message which payload is a InputStream with the file’s content, and the metadata is represent as a LocalFileAttributes object that’s placed as the message `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 blindly relying on this lock. This method also makes a best effort to determine the MIME type of the file being read. The file’s extension is used to make an educated guess on the file’s MIME type. The user also has the chance to force the output encoding and `mimeType` through the `outputEncoding` and `outputMimeType` optional parameters. #### 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. Defaults to false.

false

Time Between Size Check

Number

Wait time between size checks to determine if a file is ready to be read.

Time Between Size Check Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

time unit to be used in the wait time between size checks.

Output Mime Type

String

The MIME type of the payload that this operation outputs.

Encoding

String

The encoding of the payload that this operation outputs.

Streaming Strategy

Configure if repeatable streams should be used and their behavior

Target Variable

String

The name of a variable on which the operation’s output will be placed

Target Value

String

An expression to evaluate against the operation’s output and the outcome of that expression will be stored 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 - FILE:CONNECTIVITY - FILE:FILE\_LOCK - FILE:ILLEGAL\_PATH - FILE:RETRY\_EXHAUSTED - FILE:ACCESS\_DENIED ### Rename `` Renames the file pointed by the path to the name provided on the `to` parameter. The `to` argument should not contain any path separator. FILE:ILLEGAL\_PATH is thrown if this precondition is not honored. #### 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 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 - FILE:CONNECTIVITY - FILE:ILLEGAL\_PATH - FILE:FILE\_ALREADY\_EXISTS - FILE:RETRY\_EXHAUSTED - FILE:ACCESS\_DENIED ### Write `` Writes the content into the file pointed by path. If the directory on which the file is attempting to be written doesn’t exist, then the operation will either throw FILE:ILLEGAL\_PATH error or create such folder depending on the value of the createParentDirectory. If the file itself already exists, then the behavior depends on the supplied mode. This operation also supports locking support depending on the value of the lock argument, but following 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

x

Content

Binary

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

#[payload]

Encoding (DEPRECATED)

String

This parameter is deprecated and does nothing if configured.

Create Parent Directories

Boolean

Whether or not to attempt creating any parent directories which don’t exists.

true

Lock

Boolean

Whether or not to lock the file. Defaults to false

false

Write Mode

Enumeration, one of:

  • OVERWRITE

  • APPEND

  • CREATE_NEW

a FileWriteMode. Defaults to OVERWRITE

OVERWRITE

Reconnection Strategy

A retry strategy in case of connectivity errors.

#### For Configurations - [Default Configuration](#config) #### Throws - FILE:ILLEGAL\_CONTENT - FILE:CONNECTIVITY - FILE:ILLEGAL\_PATH - FILE:FILE\_ALREADY\_EXISTS - FILE:RETRY\_EXHAUSTED - FILE:ACCESS\_DENIED ## Sources ### On New or Updated File `` Polls a directory looking for files that have been created or updated. 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. These are the strategies for that: - Set the `autoDelete` parameter to `true`: This deletes each processed file after it has been processed, causing all files obtained in the next poll to be necessarily new. - Set `moveToDirectory` parameter: This moves each processed file to a different directory after it has been processed, achieving the same effect as `autoDelete<` but without losing the file. - Use the watermarkMode parameter to pick only files that are created or updated after the last poll was executed. A matcher can also be used for additional filtering of files. #### Parameters
NameTypeDescriptionDefault ValueRequired

Configuration

String

The name of the configuration to use.

x

Directory

String

The directory on which polled files are contained.

Recursive

Boolean

Whether or not to also files contained in sub directories.

true

Matcher

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

Watermark Mode

Enumeration, one of:

  • DISABLED

  • MODIFIED_TIMESTAMP

  • CREATED_TIMESTAMP

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

DISABLED

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.

Output Mime Type

String

The MIME type of the payload that this operation outputs.

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 if repeatable streams should be used and their behavior.

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 each file should be deleted after processing or not.

false

Move To Directory

String

If provided, each processed file will be moved to a directory pointed 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 moveToDirectory hasn’t been set as well.

Apply Post Action When Failed

Boolean

Whether any of the post actions (Auto delete and Move to directory) should also be applied in case the file failed to be processed. If set to false, no failed files are moved nor 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 will fail 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.

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.

true

### 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 Max idle time attribute.

### Local File Attributes
FieldTypeDescriptionDefault ValueRequired

Last Modified Time

DateTime

x

Last Access Time

DateTime

x

Creation Time

DateTime

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

Created Since

DateTime

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.

Created Until

DateTime

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.

Updated Since

DateTime

Files modified before this date are rejected. Any timezone specification in this value is ignored and the Mule server’s time zone is used instead.

Updated Until

DateTime

Files modified after this date are rejected. Any timezone specification in this value is ignored and the Mule server’s time zone is used instead.

Accessed Since

DateTime

Files that were last accessed before this date are rejected. Any timezone specification in this value is ignored and the Mule server’s time zone is used instead.

Accessed Until

DateTime

Files that were last accessed 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

Number

Minimum time that should pass since a file was last updated for it not to be rejected. This attribute works in tandem with Time unit.

Updated In The Last

Number

Maximum time that should pass since a file was last updated for it not to be rejected. This attribute works in tandem with Time unit.

Time Unit

Enumeration, one of:

  • NANOSECONDS

  • MICROSECONDS

  • MILLISECONDS

  • SECONDS

  • MINUTES

  • HOURS

  • DAYS

A Time unit that qualifies the Updated in the last and the Not updated in the last attributes.

MILLISECONDS

Filename Pattern

String

Path Pattern

String

Directories

Enumeration, one of:

  • REQUIRE

  • INCLUDE

  • EXCLUDE

Controls whether directories are included in the results.

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

This is the amount of memory that will be allocated in order to consume the stream and provide random access to it. If the stream contains more data than fits into this buffer, then the buffer expands according to the Buffer size increment attribute, with an upper limit of the Max in memory size.

Buffer Size Increment

Number

How much to expand the buffer size if it exceeds its initial size. Setting a value of zero or lower will mean that the buffer should not expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error is thrown when the buffer gets full.

Max in Memory Size

Number

This is the maximum amount of memory to use. If more than the specified maximum is used, then a STREAM_MAXIMUM_SIZE_EXCEEDED error is thrown. 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

Max 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 Max in memory size is expressed

In Memory Objects

Number

Defines the maximum memory the stream uses to keep data in memory. If more than the specified memory is consumed, then the system starts to buffer the content on disk.

500

### Redelivery Policy
FieldTypeDescriptionDefault ValueRequired

Max Redelivery Count

Number

The maximum number of times a message can be redelivered and processed unsuccessfully before triggering 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.

Id Expression

String

Defines one or more expressions to use to determine when a message has been redelivered. You can set this property only if Use secure hash is not selected.

Object Store

ObjectStore

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

### Local Subset List
FieldTypeDescriptionDefault ValueRequired

Limit

Number

0

Offset

Number

1

Criteria

Enumeration, one of: ALPHABETICALLY DATE_MODIFIED DATE_CREATED SIZE ** PATH

DATE_MODIFIED

Order

Enumeration, one of: ASCENDING DESCENDING

DESCENDING

### Repeatable In Memory Iterable
FieldTypeDescriptionDefault ValueRequired

Initial Buffer Size

Number

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

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 will mean that the buffer should not expand, meaning that a STREAM_MAXIMUM_SIZE_EXCEEDED error will be raised when the buffer gets full. Default value is 100 instances.

Max in Memory instances

Number

This is the maximum number of memory instances to use. If more than the specified maximum is used, then a STREAM_MAXIMUM_SIZE_EXCEEDED error is thrown. A value lower than, or equal to, zero means no limit.

### Repeatable File Store Iterable
FieldTypeDescriptionDefault ValueRequired

Max In Memory Size

Number

This is 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

### Time Between Size Check Parameter Behavior The Write operation on a file can take time to complete and get the file ready to read or access. Use the `timeBetweenSizeCheck` parameter to prevent an operation from accessing an incomplete file. When you set this parameter, it verifies the file’s size before accessing the file contents. The verification validates that the file’s size does not vary after waiting for the amount of time specified by the parameters `timeBetweenSizeCheck` and `timeBetweenSizeCheckUnit`. The `timeBetweenSizeCheck` parameter then indicates the time to wait between each verification, which is performed twice. If the file’s size remains the same during both times, this assumes that the Write operation is complete and the access operation can continue, otherwise an exception is thrown. The performed wait indicates that the thread executing the operation goes to sleep for the indicated period of time. This wait occurs at the moment of retrieving the content of the file. If the flow never accesses the content of the file, the check is not performed. > [!NOTE] In Mule runtime engine version 4.1 and 4.2, this wait can take place in multiple message > processors, and the File Connector has no control over which thread is the one performing the > wait. Any thread from any thread pool, even a CPU-intensive thread, which is not meant for this > kind of task, can be the one performing the wait. ## See Also [Salesforce Help](https://help.salesforce.com) --- product: File Connector version: 1.5 is-latest-version: true --- # File 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/file http://www.mulesoft.org/schema/mule/file/current/mule-file.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-file-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 `file`. 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: File Connector version: 1.5 is-latest-version: true --- # List Files Using the File Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Use the `List` operation to list the files and folders in the path pointed to by the `directoryPath` parameter. The `List` operation returns an array of messages in which: - Each message holds the file’s content in its payload. - The file’s message attributes section carries the file’s metadata (such as name, creation time, and size). - The payload is empty if the element is a folder. The `List` operation requires the `directoryPath` parameter, which represents the relative path of the directory to list, unless you specify the full path of the directory. The path is relative to the working directory value defined in the configuration referenced by the `config-ref` parameter. If no configuration is referenced, the working directory defaults to the value of the `user.home` system property. If the system property is not set, the connector fails to initialize. For an example of setting a configuration, see [File Connection Settings](https://docs.mulesoft.com/file-connector/latest/#connection_settings). Next is an example of a `List` operation that references a file configuration and thus uses a relative path: ```xml ``` As mentioned earlier, this returns an array of messages. In Anypoint Studio, DataSense displays the metadata for the operation’s output: ![list output](/mulesoft/current/en-us/file-connector/latest/_images/list-output.png) > [!IMPORTANT] The `List` operation lists both directories and files, but for files it also returns > a lazy stream of the file’s contents in the payload, which can then be directly consumed by other > operations. This means that you do not need to perform a `Read` operation after a `List` operation > to access the file’s content. See [Read Files Returned by List](#read-files-returned) for an > example. ## Read Files Returned by List The following example lists all files and folders in `directoryPath` and, in a `foreach` loop: ```xml ``` The `foreach` loop determines whether each element is a file or folder with a `choice` component. If the element is a file, then a [Logger](https://docs.mulesoft.com/mule-runtime/latest/logger-component-reference) outputs its path and contents. If the element is a directory, it is sent to another flow for processing. There is no `Read` operation inside the `foreach` loop because, as mentioned earlier, the `List` operation already returns the file’s content in the payload, (but in a lazy manner), so there is no need to worry about performance or overhead when the stream is not consumed in the end. ## List Files and Folders Within Subfolders To list files or folders within any subfolders of the `directoryPath`, such as a recursive list, you can set the `recursive` parameter to `true`. ```xml ``` ## Filter Files by Matching Criteria You can use the `` element to filter files based on the matching criteria you use for accepting or rejecting a file. Here is an example of file matching rules you can use: Example: File Matcher ```xml ``` All of the attributes above are optional and are ignored if not provided. They all relate to each other under an `AND` operator. ### Top-level, Reusable Matcher A file matcher can be a reusable element (a named top-level element) as shown in the following example: For example: ```xml ... ``` ### Inner Element, Non-Reusable Matcher A matcher can be an inner element that is proprietary to a particular component (non-reusable) as shown in the following example: ```xml ... ``` ## Time Between Size Checks Parameter If you want to read the file contents returned by the `List` operation, but you are not sure if the file is still being written to, you can use the `TimeBetweenSizeChecks` parameter, which works with the `TimeBetweenSizeCheckUnit` parameter. Combined, these two parameters perform two size checks: - One when the flow reaches a point where the stream is about to be consumed. The time check is not done in the `List` operation because `List` returns a lazy stream pointing to the file’s content, so it makes sense to do the size check only when the stream is about to be consumed. - Another check is performed after the wait time set by the `TimeBetweenSizeChecks` and `TimeBetweenSizeCheckUnit` parameters If both size checks return the same file size, then the stream is consumed successfully. If the two size checks return different file sizes, then the file is still being written to, so the stream is not consumed and the operation fails with an error. ## Repeatable Streams The **List** 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, refer to [Streaming in Mule Apps](https://docs.mulesoft.com/mule-runtime/latest/streaming-about). ## Limit and Sort Number of Files Returned In the **List** operation **Advanced** configuration tab, you can configure the **Subset** field to limit the number of files returned and then sort them. The limit and offset attributes are optional. ![Subset configuration screen for List operation](/mulesoft/current/en-us/file-connector/latest/_images/file-connector-subset.png) In the **Configuration XML** editor, the `` configuration looks like this: ```xml ``` ## See Also [File Connector Reference](https://docs.mulesoft.com/file-connector/latest/file-documentation) [foreach loop](https://docs.mulesoft.com/mule-runtime/latest/for-each-scope-concept) [Choice component](https://docs.mulesoft.com/mule-runtime/latest/choice-router-concept) --- product: File Connector version: 1.5 is-latest-version: true --- # Read a File Using the File Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Using Anypoint Connector for File (File Connector), the transport can read a file at any point in the flow. The only required parameter for the `Read` operation is the path to the file to be read. The path can be either the full path to the file or a relative path. The path uses the working directory value defined in the configuration referenced by the `config-ref` parameter. In Anypoint Studio, you can set the path in the **File path** field. In XML, use the **path** attribute in the ` ``` This example reads a file using the full path: ```xml ``` In Studio, click the browse button (…​) to locate the file, for example: `/Users/me/myfile` In XML, use the **path** attribute to specify the path to the file, for example: `` ## Return Information The `Read` operation returns a message with: - The file’s content as the payload - The file’s metadata in the message attributes, metadata (such as name, creation time, size, and so on) in the message attributes. If the file does not exist, the `Read` operation throws a `FILE:ILLEGAL_PATH` error. Note that the operation does not read directories. > [!NOTE] The `Read` operation (as other operations that return non-void values) supports target > parameters. See [Mule Target Variables](https://docs.mulesoft.com/mule-runtime/latest/target-variables). ## Configure a Relative Path If numerous `Read` operations (or any other file operations) in the same Mule app share part of their path, their base path can be extracted into a [file configuration](https://docs.mulesoft.com/file-connector/latest/#connection_settings) for better reuse. For example, to access two files whose full paths are `/Users/Documents/Examples/manual.txt` and `/Users/Documents/Examples/readme.txt`, you can define the part of the path that is the same in a configuration, for example: ```xml ``` The resulting `Read` operations that reference the configuration would be: ```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. ## Access Files Defined in a Mule Application While developing Mule apps, you can save folders and files in the `resources` folder. When the app is deployed, those folders and files are copied to the directory defined by the `${app.home}` property. For example, if you want to define a folder named `MyFiles` in the `resources` folder, and a file named `Example.txt` inside of the `MyFiles` folder, use this project structure: ![project resources](/mulesoft/current/en-us/file-connector/latest/_images/project-resources.png) In the runtime, the path to access the file is: `${app.home}/MyFiles/Example.txt` To read the file, define the following configuration: ```xml ``` Configure the `Read` operation like this: ```xml ``` > [!WARNING] As mentioned earlier, each time the application is deployed, the contents from the > `src/main/resources` folder are copied to the `${app.home}` directory each time the application is > deployed, any changes made to those files during runtime are lost once the application is stopped > or redeployed. For this reason, it is recommended that you put only the files needed for reading > during the application’s execution in the `resource` folder. ## File Locking You can set the `lock` parameter to `true` to prevent other processes from accessing a file while it is being read. However, because it is provided by the host file system, the lock’s behavior might change depending on the mounted drive and the operating system on which Mule is running. You must take that into consideration before relying on this lock. If the file is already locked by someone else, the connector will not be able to lock it, and the operation throws a `FILE:FILE_LOCK` error. The lock is automatically released when one of the following occurs: - The Mule flow that locked the file ends. - The file’s content is fully read. The following is an example of locking: ```xml ``` ## Modify the Output MIME Type and Encoding You can use the `outputEncoding` and `outputMimeType` parameters to change the MIME type or the encoding of the payload that the `Read` operation outputs. This does not transform the file’s content, it just overrides the MIME type or encoding information, for example: ```xml ``` ## Time Between Size Checks Parameter If you want to read the file contents returned by the `Read` operation, but you are not sure if the file is still being written to, you can use the `TimeBetweenSizeChecks` parameter, which works with the `TimeBetweenSizeCheckUnit` parameter. Combined, these two parameters perform two size checks: - One when the flow reaches a point where the stream is about to be consumed. The time check is not done in the `Read` operation because `Read` returns a lazy stream pointing to the file’s content, so it makes sense to do the size check only when the stream is about to be consumed. - Another check is performed after the wait time set by the `TimeBetweenSizeChecks` and `TimeBetweenSizeCheckUnit` parameters If both size checks return the same file size, then the stream is consumed successfully. If the two size checks return different file sizes, then the file is still being written to, so the stream is not consumed and the operation fails with an error. You can use the `Read` operation with size check parameters and then consume the output stream in a [Logger component](https://docs.mulesoft.com/mule-runtime/latest/logger-component-reference). ```xml ``` Note that the 15 seconds check happens when the `logger` component executes, not at the `Read` operation. ## Repeatable Streams The **List** 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, refer to [Streaming in Mule Apps](https://docs.mulesoft.com/mule-runtime/latest/streaming-about). --- product: File Connector version: 1.5 is-latest-version: true keywords: file, connector, trigger, listen --- # To Trigger a Flow When a New File is Created or Modified > 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. Example: File Listener (On New File Trigger) ```xml ``` ## Watermarking For the File connector, the watermarking strategy can be used in two different modes: `CREATION_TIMESTAMP` or `MODIFIED_TIMESTAMP`. The strategy depends on whether you want to filter files based on their creation or modification time. Example: Watermarking with the File Listener ```xml ``` ## Repeatable Streams The **List** 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, refer to [Streaming in Mule Apps](https://docs.mulesoft.com/mule-runtime/latest/streaming-about). --- product: File Connector version: 1.5 is-latest-version: true keywords: file, connector, write --- # To Write a File Using the File Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt A Write operation is available to the File, FTP, and SFTP connectors. For these connectors, the operation writes content into the given path on demand. It supports common use cases described below. ## Embedded DataWeave Transformations By default, the connector writes whatever is in the message payload: Example: File Connector ```xml ``` However, if the payload is a different format (for example, not CSV) and you need to transform it before writing it, what do you do? If you place a Transform component before the Write operation, the message payload changes and that impacts the operation that is placed after the Write operation. To avoid this undesired impact, you can place the transformation inside the Write operation to generate content that will be written without producing a side effect on the message in transit. The next example uses the File connector to write the content: Example: Transformation within a File Write Operation ```xml #[%dw 2.0 output application/csv --- payload.customers.email ] ``` ## Writing into Directories If any of the `a`, `b`, or `c` directories in the example below do not exist, the Write operation will fail by default. However, if you set the `createParentDirectories` to `true`, the connector will automatically create any missing directories. Example: File Connector writes to a Directory ```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. If the file already exists, then you receive an error. ## 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 any of the following modes: - **TRUE** - **FALSE (Default)** --- product: File Connector version: 1.5 is-latest-version: true --- # Troubleshooting File Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt To troubleshoot Anypoint Connector for File (File 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 File system. To resolve this error: - Use the configuration file to increase the logging level on the server side. - Try to replicate the issue using a File 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 File 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 File system. For additional information about enabling verbose logging for SDK components in your Mule application, see the [Troubleshooting SDK components](https://docs.mulesoft.com/mule-sdk/latest/troubleshooting) documentation. ## Troubleshooting Out Of Memory with Repeatable File Store Iterable In some cases where the file folder contains large files, and you set the **Streaming strategy** field to the **Repeatable file store iterable (Default)** option for the **List** operation, the Mule application might throw a `java.lang.OutOfMemoryError` message. To avoid this issue, set the **Streaming strategy** field from **Repeatable file store iterable (Default)** to the **No repeatable iterable** option. For additional information about repeatable file store, refer to [Repeatable File Store](https://docs.mulesoft.com/mule-runtime/latest/tuning-repeatable-nonrepeatable#file-store-repeatable-stream). For additional information about disabling repeatable streaming, refer to [Disable repeatable streaming](https://docs.mulesoft.com/mule-runtime/latest/streaming-about#disable_repeatable_streaming). ## Understand Common Throws Here is a list of common throw messages and how to interpret them: - FILE:CONNECTIVITY The connection to the file server is no longer valid. Apply a reconnection policy if defined in the application setup. - FILE:ILLEGAL\_PATH The **createParentDirectories** property is set to `false` and neither the target path nor its parent exists. - FILE:FILE\_ALREADY\_EXISTS The target file already exists and the **overwrite** property is set to `false`. - FILE:RETRY\_EXHAUSTED The maximum number of retries for the operation is reached. - FILE:ACCESS\_DENIED A File Connector operation attempted to access a file or a path and performed an action for which the user does not have permission. - FILE:FILE\_LOCK An attempt to lock a file was unsuccessful. - FILE:ILLEGAL\_CONTENT The **Write** operation received invalid content to write. ## See Also - [File Connector Reference](https://docs.mulesoft.com/file-connector/latest/file-documentation) - [Salesforce Help](https://help.salesforce.com) - [Known Issues](https://help.salesforce.com/s/issues) --- product: File Connector version: 1.5 is-latest-version: true --- # Using Anypoint Code Builder to Configure File Connector > For the full documentation index, see: https://docs.mulesoft.com/llms.txt Cloud IDE (Beta) is scheduled for retirement on August 31, 2026. August 30, 2026 is the last day you can access Cloud IDE (Beta). Download your projects to work from Desktop IDE. Learn more in [Migrate a Project from Cloud IDE to Desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/int-import-mule-project#migrate-cloud-to-desktop). To use Anypoint Code Builder to configure a connector or module, create a basic integration project in Anypoint Code Builder, add connectors and other components to your Mule application to process your business logic, and configure the attributes. ## Before You Begin Before creating an integration project, you must: - [Set up and access the Anypoint Code Builder web or desktop IDE](https://docs.mulesoft.com/anypoint-code-builder/start-acb) - Have credentials to access the connector’s API - Ensure that the Visual Studio Code Extension Pack for Java is installed. To use this connector, you must be familiar with: - The connector’s API - Anypoint Connectors - Mule runtime engine (Mule) ## Creating a New Integration Project To create a new integration project: 1. In the activity bar of the IDE, click the ![Anypoint Code Builder icon](/mulesoft/current/en-us/connectors/_images/acb-icon-ms-logo.png) (**Anypoint Code Builder**) icon. 2. From **Quick Actions**, click **Develop an Integration**: ![Develop an Integration link highlighted in the Getting started section](/mulesoft/current/en-us/anypoint-code-builder/_images/develop-integration-option-mat.png) 3. Complete the following in the **Develop an Integration** form:
AttributeValue

Project Name

Unique name for your project.

This name is used as the title and name of the integration project file. For example, if the project name is "Salesforce Integration," the project file name is salesforce-integration.

Project Location

Your home directory or another directory you create. Click Browse to select a different directory for the integration project.

Don’t create the project within another project directory.

4. Select the type of project to create by selecting either the **Empty Project** or **Template or Example** card. 5. Select the **Mule runtime** and **Java Version** for your app. 6. Click **Create Project**. ## Adding the Connector to Your Integration Project Anypoint Connectors provide operations for retrieving, modifying, and sending data to and from systems. In addition to the [built-in connectors](https://docs.mulesoft.com/anypoint-code-builder/acb-reference#builtin-connectors) that Anypoint Code Builder provides, you can download many other connectors from Anypoint Exchange. To import a connector from Exchange and add it to your configuration: 1. In the Explorer view, open the configuration XML file for your project, such as `my-project-name.xml`. 2. Click the ![Show Mule graphical mode icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-tree-view.png) (**Show Mule graphical mode**) icon in the activity bar to open the canvas UI if it doesn’t open automatically. 3. Add the connector the same way you added other components from the canvas UI: 1. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 2. In the **Add Component** panel, click **Connectors**. 3. Click the connector name and then click the operation to add, such as **Publish**: ![Add Publish operation from Anypoint MQ Connector](/mulesoft/current/en-us/anypoint-code-builder/_images/int-add-connector-operation.png) If the connector is not available locally, click the ![Search in Exchange icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-search-exchange.png) (**Search in Exchange**) toggle: ![Search in Exchange toggle](/mulesoft/current/en-us/anypoint-code-builder/_images/int-connector-search-exchange.png)
1Search locally
2Search in Exchange
4. Select the connector to add to your project. 5. Select the operation from the **Add Component** panel. Adding a connector to an integration project does not make that connector available to other projects in your Anypoint Code Builder workspace. ## Configuring the Trigger For the Flow A trigger (source) initiates a flow when a specified condition is met. You can configure one of these triggers to use with File Connector: - **On New or Upated File** Triggers a flow for a newly created or modified file - **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 more information, see [Scheduler ()](https://docs.mulesoft.com/anypoint-code-builder/acb-component-scheduler). For example, to configure the **On New or Updated** trigger: 1. Add the **On New or Updated** operation to the canvas UI. 2. Click the **On New or Updated** operation on the canvas UI. 3. In the **General** tab, configure the following attributes:
AttributeDescriptionRequired

Directory

Directory where polled files are located.

No

Recursive

If selected, uses files contained in sub-directories.

No

Matcher

Matcher used to filter events on files that don’t meet the matcher’s criteria.

No

Watermark mode

If selected, picks only files that were created or updated after the last poll was executed.

Options include:

  • DISABLED

  • MODIFIED_TIMESTAMP

  • CREATED_TIMESTAMP

No

Time between size check

Wait time, in milliseconds, between size checks to determine if a file is ready to read. This allows a file write to complete before processing. Mule runtime performs two size checks and waits the specified amount of time between calls. If both checks return the same value, the file is ready to read.

No

Time between size check unit

Time unit for Time between size check.

No

Scheduling strategy

Triggers the flow’s execution based on a time-based condition. This field is not currently enabled in the configuration UI. Configure it in the XML editor. See Configuring the Scheduling Strategy in XML.

Yes

Post processing action

Auto delete

If selected, deletes each processed file after it’s processed, which causes all files obtained in the next poll to be treated as new files.

No

Move to directory

Directory path to which to send each processed file after it processes. This is an alternative to Auto delete if you don’t want to delete the file.

No

Rename to

Renames a file to this value when it is moved. This attribute works in tandem with Move to directory. The connector retains the original file name if you don’t configure this field.

No

Apply post action when failed

If selected, applies any of the post actions (Auto delete and Move to directory) in case the file processing fails. If you de-select this option, no failed files are moved or deleted.

No

Overwrite

Overwrites the target file when the destination file has the same name.

No

## Adding Components to Your Project Add components to your integration project to build a flow: 1. In the **Explorer** view, open the XML file for your project, such as `my-project-name.xml`. 2. Select **Build a Flow** from the start card to create an empty flow: ![Anypoint Code Builder canvas with starting cards with the options to start from scratch, build a flow, or build a subflow](/mulesoft/current/en-us/connectors/_images/acb-build-flow.png) 3. Change the name of the flow: 1. Click **Flow**. 2. Click the edit icon. ![Arrow pointing to the flow name edit pencil icon](/mulesoft/current/en-us/connectors/_images/acb-change-flow-name.png) 3. Enter the flow name, and click the checkmark. 4. In the canvas UI, click the ![Add component icon](/mulesoft/current/en-us/anypoint-code-builder/_images/icon-plus.png) (**Add component**) icon. 5. In the **Add Component** panel, search for and select your component from the results. The following example shows the **Listener** component from the **HTTP** search results: ![Listener component highlighted in the Add Component section](/mulesoft/current/en-us/anypoint-code-builder/_images/main-tutorial-add-first-listener.png) The configuration XML file now includes the XML for the HTTP Listener into the `` element, for example: ```XML ``` ## Adding a Global Configuration Add another component, this time using the XML configuration menu. For example, add the `` component from a snippet. For more information about snippets, see [Configuring Components](https://docs.mulesoft.com/anypoint-code-builder/int-configure-components). 1. In the configuration XML, place your cursor before the `` element and type `http`. Ensure that the cursor is not inside the `` element. 2. Type `http`, and select the `http:listener-config` snippet: ![http:listener-config snippet highlighted in the configuration XML menu](/mulesoft/current/en-us/anypoint-code-builder/_images/add-http-config-snippet.png) The snippet adds the following code: ```xml ``` ## Configuring Component Attributes After you add components to your integration project, configure the attributes in the component UI, or configure the attributes directly in the XML code editor. Connector XML tags start with a namespace followed by an operation, following the syntax `namespace:operation`, such as `` for a **Select** operation in Anypoint Connector for Database (Database Connector). You can use autocomplete from an expression (**fx**) field for a component to select DataWeave functions from the Core module and other values accepted in this field. ### Configuring the Copy Operation The **Copy** operation copies the file or directory specified in **Source Path** into the **Target Path**. The source path can be either a file or directory. If **Source Path** points to a directory, then the directory is copied recursively. 1. Click the **Copy** operation on the canvas UI to configure the following attributes in the **General** tab:
AttributeDescriptionRequired

Source path

Path to the file or directory to perform the operation on.

Yes

Target path

Path to the directory to place the file in.

Yes

Create parent directories

If selected, a parent folder is created if the target path or its parent don’t exist. If unselected, a FILE:ILLEGAL_PATH error is thrown when you try to perform the operation.

No

Overwrite

If selected, overwrites the target file if a file already exists. If Overwrite isn’t selected, a FILE:FILE_ALREADY_EXISTS error is thrown when you try to perform the operation.

No

Rename to

New name for the file. If a new name isn’t provided, the original file name is kept.

No

2. Click the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Connection

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Create Directory Operation The **Create Directory** operation creates a directory in the specified **Directory path**. 1. Click the **Create Directory** operation on the canvas UI to configure the following attributes in the **General** tab:
AttributeDescriptionRequired

Directory path

New directory’s path name, for example ~/newFolder.

Yes

2. Click the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Connection

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Delete Operation The **Delete** operation deletes the file specified in the **Directory path**, as long as the file isn’t locked. This operation doesn’t delete directories. 1. Click the **Delete** operation on the canvas UI to configure the following attributes in the **General** tab:
AttributeDescriptionRequired

Directory path

Path to the file to delete.

Yes

2. Click the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Connection

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the List Operation Use the **List** operation to list all files in the specified **Directory path**. 1. Click the **List** operation on the canvas UI to configure the following attributes in the **General** tab:
AttributeDescriptionRequired

Directory path

Path to the directory with the files to list.

Yes

Recursive

If selected, the contents of sub-directories are also listed in the output.

No

File Matching Rules

Filters files based on the matching criteria that you use for accepting or rejecting a file. For an example of file matching rules, see Filter Files by Matching Criteria.

No

2. Click the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Time between size check

Wait time, in milliseconds, between size checks to determine if a file is ready to read. This allows a file write to complete before processing. Mule runtime performs two size checks and waits the specified amount of time between calls. If both checks return the same value, the file is ready to read.

No

Time between size check unit

Time unit for Time between size check.

No

Subset

Limits and sorts the number of files returned.

No

Streaming strategy

Configures the way data streams are consumed in Mule apps. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Configuring the Streaming Strategy in XML.

No

Target Variable

Name of the variable on which the operation’s output is placed.

No

Target Value

Expression that’s evaluated against the operation’s output. The outcome of this expression is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Move Operation The **Move** operation moves the file or directory from the **Source path** to the **Target Path**. If the **Source path** points to a directory, then the directory is moved recursively. 1. Click the **Move** operation on the canvas UI to configure the following attributes in the **General** tab:
AttributeDescriptionRequired

Source path

Path to the file or directory to perform the operation on.

Yes

Target path

Path to the directory to place the file in.

Yes

Create parent directories

If selected, a parent folder is created if the target path or its parent don’t exist. If unselected, a FILE:ILLEGAL_PATH error is thrown when you try to perform the operation.

No

Overwrite

If selected, overwrites the target file if a file already exists. If Overwrite isn’t selected, a FILE:FILE_ALREADY_EXISTS error is thrown when you try to perform the operation.

No

Rename to

New name for the file. If a new name isn’t provided, the original file name is kept.

No

2. Click the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Connection

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Read Operation The **Read** operation reads the contents and metadata of a file at the specified path and returns a message whose payload is an input stream containing the file’s contents. The metadata is represented as a `LocalFileAttributes` object that’s expressed as message attributes (`Message#getAttributes()`). The file’s MIME type is based on the file’s extension. You can force the output encoding and MIME type by using the optional **Output MIME type** and **Output encoding** parameters. 1. Click the **Read** operation on the canvas UI to configure the following attributes in the **General** tab:
AttributeDescriptionRequired

File Path

Path to the file to read.

Yes

2. Click the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Lock

If selected, places a file system-level lock on the file until the input stream that the operation returns is closed or fully consumed. The lock is provided by the host file system, so its behavior might change depending on the mounted drive and the operation system on which Mule runtime is running.

No

Time between size check

Wait time, in milliseconds, between size checks to determine if a file is ready to read. This allows a file write to complete before processing. Mule runtime performs two size checks and waits the specified amount of time between calls. If both checks return the same value, the file is ready to read.

No

Time between size check unit

Time unit for Time between size check.

No

Output MIME type

MIME type of the payload that this operation outputs.

No

Parameters

One or more key-value pairs to append to the value of the Output MIME type attribute. Multiple key-value pairs are allowed. These key-value pairs enable you to store data in a variable so that any component in the flow can use it.

No

Output encoding

Encoding of the payload that this component outputs.

No

Streaming Strategy

Configure the way data streams are consumed in Mule apps. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Configuring the Streaming Strategy in XML.

No

Target Variable

Name of the variable on which the operation’s output is placed.

No

Target Value

Expression that’s evaluated against the operation’s output. The outcome of this expression is stored in the target variable.

No

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Rename Operation The **Rename** operation renames the file specified in the **Path** field to the name provided in the `to` parameter. If the `to` parameter contains path separators, a `FILE:ILLEGAL_PATH` is thrown. 1. Click the **Rename** operation on the canvas UI to configure the following attributes in the **General** tab:
AttributeDescriptionRequired

Path

Path to the file to rename.

Yes

New Name

New name for the file.

Yes

Overwrite

If selected, overwrites the target file if a file already exists with the name you specified in New Name.

No

2. Click the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Connection

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

### Configuring the Write Operation The **Write** operation writes content into the file specified in **Path**. 1. Click the **Write** operation on the canvas UI to configure the following attributes in the **General** tab:
AttributeDescriptionRequired

Path

Path to the directory that contains the file to write content to.

Yes

Content

Content to write to the file. Defaults to the Content payload.

No

Create parent directories

If selected, a parent folder is created if the target path or its parent don’t exist. If unselected, a FILE:ILLEGAL_PATH error is thrown when you try to perform the operation.

No

Write Mode

What to do if the file already exists. The options include:

  • OVERWRITE (Default)

  • APPEND

  • CREATE_NEW

No

2. Click the **Advanced** tab to configure the following attributes:
AttributeDescriptionRequired

Error Mappings

Creates custom error types that you map to Mule error types. The mappings can help you further differentiate and group errors in your app. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Mule Errors.

No

Connection

Reconnection strategy

When an operation in a Mule application fails to connect to an external server, the default behavior is for the operation to fail immediately and return a connectivity error. You can modify the default behavior by configuring the reconnection strategy for the operation. This attribute is not currently enabled in the configuration UI. Configure it in the XML editor. See Reconnect and Reconnect Forever, and Configuring the Reconnection Strategy in XML.

No

3. Select **Lock** to place a file-system-level lock on the file until the input stream that the operation returns is closed or fully consumed. ## Configuring the Scheduling Strategy in XML ### Fixed Frequency This is an example of the fixed frequency scheduling strategy XML using the default values: ```xml ``` ### Cron For more complex scheduling strategies, you can use a cron expression: ```xml ``` ## Configuring the Reconnection Strategy in XML The following is an XML example of a standard reconnection strategy setting the count of reconnection attempts before failing to `5` and setting `failsDeployment` to true, which causes the application deployment to fail if the connection test fails. Because a frequency is not specified, the retry interval is the default of every 2000 ms: ```xml ``` The following is an XML example of a reconnect forever strategy where the connector attempts to reconnect every 4000 ms for as long as the application runs: ```xml ``` ## Configuring the Streaming Strategy in XML You can configure how Mule handles data streams with streaming strategies. ### File-Stored Repeatable Stream The following is an XML example of reading a file that is configured with a 1 MB buffer: ```xml ``` If you consistently process a file that’s no larger than 10 KB, you can save memory by reducing the `inMemorySize` attribute: ```xml ``` ### In-Memory Repeatable Stream The following XML example shows an in-memory repeatable stream with a 512 KB initial size, which grows at a rate of 256 KB and allows up to 2000 KB (2 MB) of content in memory: ```xml ``` --- product: File Connector version: 1.5 is-latest-version: true --- # Using Anypoint Studio to Configure File Connector 1.5 > 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 [File Connector Reference Reference](https://docs.mulesoft.com/file-connector/latest/file-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 File 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 `file` in the search field. 3. Click **File 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 File 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 File Connector, follow these steps: 1. In the **Mule Palette** view, select **File** and then select the desired operation. 2. Drag the operation onto the Studio canvas, next to the source. ## 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 File 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 value of the `user.home` system property. If the system property is not set, the connector fails to initialize. 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**. In the **Configuration XML** editor, the configuration `file: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) - [File Connector Reference](https://docs.mulesoft.com/file-connector/latest/file-documentation) - [Salesforce Help](https://help.salesforce.com)