String
SFTP Connector Reference - Mule 4
SFTP Connector v2.4
Anypoint Connector for SFTP (SFTP Connector) provides access to files and folders on a SFTP server.
Release Notes: SFTP Connector Release Notes
PPK (Private Key) file does not support identity file for SFTP Connector. |
Configurations
Default Configuration
Parameters
Name | Type | Description | Default Value | Required |
---|---|---|---|---|
Name |
The name for this configuration. Connectors reference the configuration with this name. |
x |
||
Connection |
The connection types to provide to this configuration. |
x |
||
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 will not be performed. When enabled, Mule waits the specified time between calls and performs two size checks. If both checks return the same value, the file is ready to read. This attribute works in tandem with Time Between Size Check Unit. |
||
Time Between Size Check Unit |
Enumeration, is one of:
|
A TimeUnit that qualifies the Time Between Size Check attribute. + Defaults to |
|
|
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. Mule runtime engine purges the instances when it sees it fit. |
Connection Types
SFTP Connection
A file system provider that provides instances of SFTP file system from instances of SFTP Connector.
Parameters
Name | Type | Description | Default Value | Required |
---|---|---|---|---|
Working Directory |
String |
The directory designated as the root of every relative path used with this connector. If not provided, it defaults to the remote server default. Define a working directory because some SFTP servers do not return output for the present working directory command. While the behavior of the SFTP server side cannot be controlled, setting this value mitigates such scenario. |
||
Preferred Authentication Methods |
Array of enumeration is one of:
|
Set of authentication methods used by the SFTP client. Valid values are: |
||
Known Hosts File |
String |
If provided, the client validates the server’s key against the one in the referenced file. If the server key doesn’t match the one in the file, the connection will be aborted. |
||
Sftp Proxy Config |
If provided, a proxy will be used for the connection. |
|||
Connection Timeout |
Number |
A scalar value representing the amount of time to wait before a connection attempt times out. This attribute works in tandem with Connection Timeout Unit. |
|
|
Connection Timeout Unit |
Enumeration is one of:
|
A time unit that qualifies the Connection Timeout attribute. + Defaults to |
|
|
Response Timeout |
Number |
A scalar value representing the amount of time to wait before a request for data times out. This attribute works in tandem with Response Timeout Unit. + Defaults to |
|
|
Response Timeout Unit |
Enumeration is one of:
|
A TimeUnit that qualifies the Response Timeout Unit attribute. + Defaults to |
|
|
Host |
String |
The SFTP server host, such as |
x |
|
Port |
Number |
The port number of the SFTP server to connect on. |
|
|
Username |
String |
Username for the SFTP Server. Required if the server is authenticated. |
||
Password |
String |
Password for the SFTP Server. Required if the server is authenticated. |
||
Passphrase |
String |
The passphrase (password) for the identity file if required. This parameter is ignored if identity file is not provided. |
||
Identity File |
String |
An identity file location for a PKI private key. |
||
PRNG Algorithm |
Enumeration is one of:
|
The Pseudo Random Number Generator Algorithm to use. |
AUTOSELECT |
|
Security Configuration |
Provides support to override security related configurations like Ciphers, MACs, Kex Algorithms, etc. |
|||
Reconnection |
When the application is deployed, a connectivity test is performed on all connectors. If set to |
|||
Pooling Profile |
Characteristics of the connection pool. |
Operations
Copy
<sftp:copy>
Copies the file or directory specified in Source Path into the Target Path. The source path can be either a file or a directory. If it points to a directory, then it is copied recursively.
If the target path doesn’t exist, and neither does its parent, then a parent folder is created if Create parent directories is set to true
. If Create parent directories is set to false
, then an SFTP:ILLEGAL_PATH
error is thrown.
If Overwrite is set to true
and the target file already exists, then the target file is overwritten. Otherwise, an SFTP:FILE_ALREADY_EXISTS
error is thrown.
Parameters
Name | Type | Description | Default Value | Required |
---|---|---|---|---|
Configuration |
String |
The name of the configuration to use. |
x |
|
Source Path |
String |
The path to the file to copy. |
x |
|
Target Path |
String |
The target directory for where to copy the file. |
x |
|
Create Parent Directories |
Boolean |
Whether or not to attempt 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 |
Rename the copied file. If this value is not provided, the original file name is kept. |
||
Reconnection Strategy |
A retry strategy in case of connectivity errors. |
Create Directory
<sftp:create-directory>
Creates a new directory using the value in the Directory Path field.
Delete
<sftp:delete>
Deletes the file that the path field points to, provided that the file is not locked.
List
<sftp:list>
Lists all the files in the Directory Path depending on the rules in the File Matching Rules field.
If the listing encounters a directory, the output list will include its contents, depending on the value of the Recursive field.
If Recursive is set to the true
value, but a found directory is rejected by the rules in the File Matching Rules field, then recursion does not occur in the directory.
Parameters
Name | Type | Description | Default Value | Required |
---|---|---|---|---|
Configuration |
String |
The name of the configuration to use. |
x |
|
Directory Path |
String |
The directory path to list. |
x |
|
Recursive |
Boolean |
Whether to include the contents of subdirectories. Defaults to |
|
|
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 is one of:
|
Time unit to use in the wait time between size checks. |
||
Streaming Strategy |
|
Configure whether to use repeatable streams. |
||
Target Variable |
String |
The name of a variable to store the operation’s output. |
||
Target Value |
String |
An expression to evaluate against the operation’s output and store the expression outcome in the target variable. |
|
|
Reconnection Strategy |
A retry strategy in case of connectivity errors. |
Output
Type |
Array of Message of [String] payload and [SFTP File Attributes] attributes. The payload contains the element path. |
Move
<sftp:move>
Moves the file or directory from the Source Path into the Target Path. The source path can be either a file or a directory. If it points to a directory, then it will be moved recursively.
If the target path doesn’t exist, and neither does its parent, then a parent folder is created if Create parent directories is set to true
. If Create parent directories is set to false
, then an SFTP:ILLEGAL_PATH
error is thrown.
If the target file already exists, then it will be overwritten if Overwrite is set to true
. If Overwrite is set to false
, an SFTP:FILE_ALREADY_EXISTS
error will be thrown.
Parameters
Name | Type | Description | Default Value | Required |
---|---|---|---|---|
Configuration |
String |
The name of the configuration to use. |
x |
|
Source Path |
String |
The path to the file to copy. |
x |
|
Target Path |
String |
The target directory. |
x |
|
Create Parent Directories |
Boolean |
Whether or not to attempt to create any parent directories that don’t exist. |
|
|
Overwrite |
Boolean |
Whether or not to overwrite the file if the target destination already exists. |
|
|
Rename To |
String |
Name of the moved file. If a value is not provided, the original file name is kept. |
||
Reconnection Strategy |
A retry strategy in case of connectivity errors. |
Read
<sftp:read>
Obtains the content and metadata of a file at a given path. The operation itself returns a message whose payload is an input stream with the file’s content, and the metadata is represented as an SftpFileAttributes
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 provided by the host file system, its behavior might change depending on the SFTP server or its file system. Take that into consideration before relying on this lock.
This method also makes a best effort to determine the MIME type of the file being read by using the file’s extension to make an educated guess. You can also use the output Encoding and output MIME Type optional parameters to force the encoding and MIME type.
Parameters
Name | Type | Description | Default Value | Required |
---|---|---|---|---|
Configuration |
String |
The name of the configuration to use. |
x |
|
File Path |
String |
The path to the file to read. |
x |
|
Lock |
Boolean |
Whether or not to lock the file. Defaults to |
|
|
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 is one of:
|
Time unit to use in the wait time between size checks. |
||
Output Mime Type |
String |
The MIME type of the payload that this operation outputs. |
||
Output Encoding |
String |
The encoding of the payload that this operation outputs. |
||
Streaming Strategy |
|
Configure whether to use repeatable streams. |
||
Target Variable |
String |
The name of a variable to store the operation’s output. |
||
Target Value |
String |
An expression to evaluate against the operation’s output and store the expression outcome in the target variable. |
#[payload] |
|
Reconnection Strategy |
A retry strategy in case of connectivity errors. |
Rename
<sftp:rename>
Renames the file to which the path points to the value provided in the New Name parameter. This argument should not contain any path separator, or an SFTP:ILLEGAL_PATH
error will be thrown.
Parameters
Name | Type | Description | Default Value | Required |
---|---|---|---|---|
Configuration |
String |
The name of the configuration to use. |
x |
|
Path |
String |
The path to the file to rename. |
x |
|
New Name |
String |
The file’s new name. |
x |
|
Overwrite |
Boolean |
Whether or not to overwrite the file if the target destination already exists. |
|
|
Reconnection Strategy |
A retry strategy in case of connectivity errors. |
Write
<sftp:write>
Writes the content into the file the path points to.
If the directory to which the file is attempting to be written doesn’t exist, then the operation will either throw an SFTP:ILLEGAL_PATH
error, or create a new folder, depending on the value of Create parent directories. If the file already exists, then the behavior depends on the supplied mode.
This operation also supports locking depending on the value of the lock argument, and follows the same rules and considerations as described in the read operation.
An additional check is performed if the file already exists, thus the FTP STAT command is executed before writing the file.
|
Parameters
Name | Type | Description | Default Value | Required |
---|---|---|---|---|
Configuration |
String |
The name of the configuration to use. |
x |
|
Path |
String |
The path of the file to write. |
x |
|
Content |
Binary |
The content to write into the file. Defaults to the current Message payload. |
|
|
Create Parent Directories |
Boolean |
Whether or not to attempt to create any parent directories that don’t exist. |
|
|
Lock |
Boolean |
Whether or not to lock the file. Defaults to |
|
|
Write Mode |
Enumeration is one of:
|
A |
|
|
Write Strategy |
Enumeration, one of:
|
Strategy to write the file. |
|
|
Buffer Size For Write Strategy |
Enumeration, one of:
|
Buffer size for the custom write. |
|
|
Config Ref |
ConfigurationProvider |
Configuration name to execute the write strategy. |
x |
|
Reconnection Strategy |
A retry strategy in case of connectivity errors. |
Sources
On New or Updated File
<sftp:listener>
Polls a directory and looks for files that have been created in it. One message is generated for each file that is found.
The key part of this functionality is how to determine that a file is actually new. There are three strategies for that:
-
Set the Auto delete parameter to
true
to delete each file after it is processed, which causes all files obtained in the next poll to be necessarily new. -
Set the Move to directory parameter to move each file to a different directory after it is processed, which achieves the same effect as Auto delete but without losing the file.
-
Use Watermark enabled to pick only files that have been created or updated after the last poll was executed.
You can also use a matcher for additional filtering of files.
The On New Or Updated File source ignores files that return with an empty attributes list. The list can be empty if the modification time (MDTM) is not enabled by the SFTP server or if the server returns an error when listing the attributes.
Parameters
Name | Type | Description | Default Value | Required |
---|---|---|---|---|
Configuration |
String |
The name of the configuration to use. |
x |
|
Directory |
String |
The directory in which polled files are contained. |
||
Recursive |
Boolean |
Whether or not to also poll files contained in sub directories. |
true |
|
Matcher |
A matcher used to filter events on files that do not meet the file matching criteria. |
|||
Watermark Enabled |
Boolean |
Controls whether or not to do watermarking, and if so, if the watermark should consider the file’s modification or creation timestamps. Enable this field to have the connector pick only files that were created or updated after the completion of the latest poll. |
false |
|
Time Between Size Check |
Number |
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. 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 read. |
||
Time Between Size Check Unit |
Enumeration is one of:
|
A TimeUnit which qualifies the Time between size check attribute. |
||
Output Mime Type |
String |
The MIME type of the payload that this operation outputs. |
||
Output Encoding |
String |
The encoding of the payload that this operation outputs. |
||
Primary Node Only |
Boolean |
Whether this source should be executed only on the primary node when running in a cluster. |
||
Scheduling Strategy |
scheduling-strategy |
Configures the scheduler that triggers the polling. |
x |
|
Streaming Strategy |
|
Configure whether to use repeatable streams. |
||
Redelivery Policy |
Defines a policy for processing the redelivery of the same message. |
|||
Reconnection Strategy |
A retry strategy in case of connectivity errors. |
|||
Auto Delete |
Boolean |
Whether to delete each file after processing. |
|
|
Move To Directory |
String |
If provided, each processed file will be moved to a directory that is pointed to by this path. |
||
Rename To |
String |
This parameter works in tandem with Move to directory. Use this parameter to enter the name of the directory under which to move the file. Do not set this parameter if Move to directory hasn’t also been set. |
||
Apply Post Action When Failed |
Boolean |
Specifies whether any of the post actions (Auto delete and Move to directory) should also be applied in case the file fails to be processed. If set to |
|
|
Overwrite |
Boolean |
Enables you to overwrite the target file when the destination file has the same name. |
|
Types
SFTP Proxy Config
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Host |
String |
x |
||
Port |
Number |
x |
||
Username |
String |
|||
Password |
String |
|||
Protocol |
Enumeration is of:
|
x |
Security Configuration
Configuring security settings using the SSH Config Override File means you accept the shared responsibilities documentation.
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
SSH Config Override File |
String |
Path to the file with the SSH override configurations. It supports the following configs:
You define the keys in the file you need to override, defaults are taken for the remaining keys. |
Reconnection
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Fails Deployment |
Boolean |
When the application is deployed, a connectivity test is performed on all connectors. If set to |
||
Reconnection Strategy |
The reconnection strategy to use. It overrides the |
Reconnect
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Frequency |
Number |
How often (in milliseconds) to reconnect. |
||
Count |
Number |
How many reconnection attempts to make. |
||
blocking |
Boolean |
If |
|
Reconnect Forever
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Frequency |
Number |
How often (in milliseconds) to reconnect. |
||
blocking |
Boolean |
If |
|
Pooling Profile
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Max Active |
Number |
Controls the maximum number of Mule components that can be active at one time. When set to a negative value, there is no limit to the number of components that can be active at one time. When Max active is exceeded, the pool is exhausted. |
5 |
|
Max Idle |
Number |
Controls the maximum number of Mule components that can sit idle in the pool at any one time. When set to a negative value, there is no limit to the number of Mule components that can be idle at one time. |
5 |
|
Max Wait |
Number |
Specifies the number of milliseconds to wait for a pooled component to become available when the pool is exhausted and the Exhausted action is set to |
5 |
|
Min Eviction Millis |
Number |
Determines the minimum amount of time an object can sit idle in the pool before it is eligible for eviction. When non-positive, no objects will be evicted from the pool due to idle time alone. |
1800000 |
|
Eviction Check Interval Millis |
Number |
Specifies the number of milliseconds between runs of the object evictor. When non-positive, no object evictor is executed. |
-1 |
|
Exhausted Action |
Enumeration is one of:
|
Specifies the behavior of the Mule component pool when the pool is exhausted. Possible values are:
|
WHEN_EXHAUSTED_GROW |
|
Initialisation Policy |
Enumeration is one of:
|
Determines how components in a pool should be initialized. The possible values are:
|
INITIALISE_NONE |
Expiration Policy
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
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 is one of:
|
A time unit that qualifies the Max idle time attribute. |
SFTP File Attributes
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Timestamp |
DateTime |
x |
||
Size |
Number |
x |
||
Regular File |
Boolean |
false |
||
Directory |
Boolean |
false |
||
Symbolic Link |
Boolean |
false |
||
Path |
String |
x |
||
File Name |
String |
x |
Matcher
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Timestamp 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. |
||
Timestamp 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. |
||
Not Updated In The Last |
Number |
Minimum time that should pass since a file was last updated to not be rejected. This attribute works in tandem with Time unit. |
||
Updated In The Last |
Number |
Maximum time that should pass from when a file was last updated to not be rejected. This attribute works in tandem with Time unit. |
||
Time Unit |
Enumeration is one of:
|
A Not updated in the last attributes.
|
MILLISECONDS |
|
Case Sensitive |
Boolean |
Enables you to configure an external file system matcher as case sensitive or insensitive. |
true |
|
Filename Pattern |
String |
A matching pattern to apply on the file name. Supports glob expressions (default) and regex expressions. To use any of the expressions set a prefix, for example, |
||
Path Pattern |
String |
A matching pattern to apply on the file path |
||
Directories |
Enumeration is one of:
|
Match only if the file is a directory |
INCLUDE |
|
Regular Files |
Enumeration is one of:
|
Match only if the file is a regular file |
INCLUDE |
|
Sym Links |
Enumeration is one of:
|
Match only if the file is a symbolic link |
INCLUDE |
|
Min Size |
Number |
The minimum file size in bytes. Files smaller than the specified value are rejected. |
||
Max Size |
Number |
The maximum file size in bytes. Files larger than the specified value are rejected. |
Repeatable In Memory Stream
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Initial Buffer Size |
Number |
This is the amount of memory to allocate to consume the stream and provide random access to it. If the stream contains more data than can fit into this buffer, then it will be expanded according to the Buffer size increment attribute, with an upper limit of Max in memory size. |
||
Buffer Size Increment |
Number |
This is by how much the buffer size will be expanded if it exceeds its initial size. Setting a value of zero or lower means that the buffer should not expand, and that a |
||
Max Buffer Size |
Number |
This is the maximum amount of memory to use. If more than the specified maximum is used, then a |
||
Buffer Unit |
Enumeration is one of:
|
The unit in which all these attributes are expressed. |
Repeatable File Store Stream
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
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 content is buffered on the disk. |
||
Buffer Unit |
Enumeration, one of:
|
The unit in which maxInMemorySize is expressed |
Redelivery Policy
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
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 |
||
Id Expression |
String |
Defines one or more expressions to use to determine when a message has been redelivered. This property may only be set if useSecureHash is false. |
||
Object Store |
ObjectStore |
The object store where the redelivery counter for each message will be stored. |
Repeatable In Memory Iterable
Field | Type | Description | Default Value | Required |
---|---|---|---|---|
Initial Buffer Size |
Number |
This is the number of instances initially 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 can fit into this buffer, then it will be expanded according to the Buffer size increment attribute, with an upper limit of Max in memory size. Default value is 100 instances. |
||
Buffer Size Increment |
Number |
How much the buffer size will expand if it exceeds its initial specified size. Setting a value of zero or lower means that the buffer should not expand, and that a |
||
Max in Memory Instances |
Number |
This is the maximum amount of memory to use. If more than the maximum amount is used, then a |