File Connector - Mule 4
File Connector v1.3
Anypoint Connector for File (File Connector) handles files and folders on a locally mounted file system. Its main features include:
The ability to read files or fully list directory contents on demand.
Support for common FTP operations such as creating directories and copying, moving, renaming, and deleting files.
Support for locking files.
File matching functionality.
A design that is fully consistent with the File and SFTP connectors. The same set of operations is available on each connector.
For information on error conditions, see the File Connector Reference.
Release Notes: File Connector Release Notes
Exchange: File Connector
Configure the File Connector
The File connector does not always require configuration. However, it is good practice to define one. The most important configuration parameter is the Working Directory (
workingDir), which is the path to a directory that is treated as the root of every relative path that you specify with this connector. If you do not provide a working directory, the connector configuration defaults to the value of the
user.home system property. If the system property is not set, the connector fails to initialize.
You can also set the default encoding to use when writing files. It defaults to Mule runtime’s default encoding. If you use any File connector operations without referencing a configuration, the operation uses the default values.
This example sets a working directory for the File connector:
<file:config name="File_Config"> <file:connection workingDir="/Users/me/myfiles" /> </file:config>
When reading or listing files, the connector provides file metadata, such as the file name, full path, size, timestamp, and so on. The connector uses the Mule Message Attributes to access this information.
POM File Information
<dependency> <groupId>org.mule.connectors</groupId> <artifactId>mule-file-connector</artifactId> <version>x.x.x</version> <classifier>mule-plugin</classifier> </dependency>
x.x.x with the version that corresponds to the connector you are using. To specify a version, view
File Connector in
Anypoint Exchange and click Dependency Snippets.