File Connector Reference¶
The following operations allow you to work with the File Connector version 2. Click an operation name to see parameter details and samples on how to use it.
append
The append operation appends content to an existing file in a specified location.
Parameter Name | Description | Required |
---|---|---|
destination | The location of the file for which content needs to be appended. | Yes |
inputContent | The content to be appended. | Yes |
position | Position to append the content. If you provide a valid position, content will be appended to that position. Otherwise, content will be appended at the end of the file. | Yes |
encoding | The encoding that is supported. Possible values are US-ASCII, UTF-8, and UTF-16. | Optional |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
sftpIdentities | Location of the private key. | Optional |
sftpIdentityPassphrase | Passphrase of the private key. | Optional |
Sample configuration
<fileconnector.append>
<destination>{$ctx:destination}</destination>
<inputContent>{$ctx:inputContent}</inputContent>
<position>{$ctx:position}</position>
<encoding>{$ctx:encoding}</encoding>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
<sftpIdentities>{$ctx:sftpIdentities}</sftpIdentities>
<sftpIdentityPassphrase>{$ctx:sftpIdentityPassphrase}</sftpIdentityPassphrase>
</fileconnector.append>
Sample request
Following is a sample REST/JSON request that can be handled by the append operation.
{
"destination":"/home/vive/Desktop/file/append.txt",
"inputContent":"Add Append Text."
}
archive
The archive operation archives files or folders. This operation supports the ZIP archive type.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. This can be a file on the local physical file system or a file on an FTP server.
|
Yes |
destination | The location of the archived file with the file name. (e.g., file:///home/user/test/test.zip) | Yes |
inputContent | The input content that needs to be archived. | Yes |
fileName | The name of the file where input content needs to be archived. | Yes |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
sftpIdentities | Location of the private key. | Optional |
sftpIdentityPassphrase | Passphrase of the private key. | Optional |
NOTE: To make an archive operation, you can provide either the source or inputContent. If inputContent is provided as the parameter, we need to specify fileName. Otherwise, it will use the default fileName (output.txt).
Sample configuration
<fileconnector.archives>
<source>{$ctx:source}</source>
<destination>{$ctx:destination}</destination>
<inputContent>{$ctx:inputContent}</inputContent>
<fileName>{$ctx:fileName}</fileName>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
<sftpIdentities>{$ctx:sftpIdentities}</sftpIdentities>
<sftpIdentityPassphrase>{$ctx:sftpIdentityPassphrase}</sftpIdentityPassphrase>
</fileconnector.archives>
Sample request
Following is a sample REST/JSON request that can be handled by the archive operation.
{
"source":"/home/vive/Desktop/file",
"destination":"/home/user/test/file.zip"
}
copy
The copy operation copies files from one location to another. This operation can be used when you want to copy any kind of files and large files as well. You can also copy particular files with specified file patterns.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. This can be a file on the local physical file system or a file on an FTP server.
|
Yes |
destination | The location of the archived file with the file name. (e.g., file:///home/user/test/test.zip) | Yes |
filePattern | The pattern of the files to be copied. (e.g., [a-zA-Z][a-zA-Z]*.(txt|xml|jar)) | Optional |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
includeParentDirectory | Set to true if you want to include the parent directory. | Optional |
sourceSftpIdentities | Location of the source's private key. | Optional |
sourceSftpIdentityPassphrase | Passphrase of the source's private key. | Optional |
targetSftpIdentities | Location of the target's private key. | Optional |
targetSftpIdentityPassphrase | Passphrase of the target's private key. | Optional |
Sample configuration
<fileconnector.copy>
<source>{$ctx:source}</source>
<destination>{$ctx:destination}</destination>
<filePattern>{$ctx:filePattern}</filePattern>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
<includeParentDirectory>{$ctx:includeParentDirectory}</includeParentDirectory>
<sourceSftpIdentities>{$ctx:sftpIdentities}</sourceSftpIdentities>
<sourceSftpIdentityPassphrase>{$ctx:sourceSftpIdentityPassphrase}</sourceSftpIdentityPassphrase>
<targetSftpIdentities>{$ctx:targetSftpIdentities}</targetSftpIdentities>
<targetSftpIdentityPassphrase>{$ctx:targetSftpIdentityPassphrase}</targetSftpIdentityPassphrase>
</fileconnector.copy>
Sample request
{
"source":"/home/vive/Desktop/file",
"destination":"/home/user/test/fileCopy",
"filePattern":".*\.xml",
"includeParentDirectory":"false"
}
create
The create operation creates a file or folder in a specified location. When creating a file, you can either create the file with content or without content.
Parameter Name | Description | Required |
---|---|---|
filePath | The location of the file. This can be a file on the local physical file system or a file on an FTP server.
|
Yes |
inputContent | The content of the file. | Optional |
encoding | The encoding that is supported. Possible values are US-ASCII, UTF-8, and UTF-16. | Optional |
isBinaryContent | Set to true if input content should be handled as binary data. Input content is expected to be base64 encoded binary content. | Optional |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
sftpIdentities | Location of the private key. | Optional |
sftpIdentityPassphrase | Passphrase of the private key. | Optional |
Sample configuration
<fileconnector.create>
<filePath>{$ctx:filePath}</filePath>
<inputContent>{$ctx:inputContent}</inputContent>
<encoding>{$ctx:encoding}</encoding>
<isBinaryContent>{$ctx:isBinaryContent}</isBinaryContent>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
<sftpIdentities>{$ctx:sftpIdentities}</sftpIdentities>
<sftpIdentityPassphrase>{$ctx:sftpIdentityPassphrase}</sftpIdentityPassphrase>
</fileconnector.create>
Sample request
{
"filePath":"sftp://UserName:Password@Host/home/connectors/create.txt",
"inputContent":"InputContent Text",
"encoding":"UTF8"
}
delete
The delete operation deletes a file or folder from the file system.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. This can be a file on the local physical file system or a file on an FTP server.
|
Yes |
filePattern | The pattern of the files to be deleted.(e.g., [a-zA-Z][a-zA-Z]*.(txt|xml|jar)). | Optional |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
deleteContainerFolders | Set to true if you want to delete the container folders. | Optional |
sftpIdentities | Location of the private key. | Optional |
sftpIdentityPassphrase | Passphrase of the private key. | Optional |
Sample configuration
<fileconnector.delete>
<source>{$ctx:source}</source>
<filePattern>{$ctx:filePattern}</filePattern>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
<deleteContainerFolders>{$ctx:deleteContainerFolders}</deleteContainerFolders>
<sftpIdentities>{$ctx:sftpIdentities}</sftpIdentities>
<sftpIdentityPassphrase>{$ctx:sftpIdentityPassphrase}</sftpIdentityPassphrase>
</fileconnector.delete>
Sample request
{
"source":"/home/vive/Desktop/file",
"filePattern":".*\.txt"
}
isFileExist
The isFileExist operation checks the existence of a file in a specified location. This operation returns true if the file exists and returns false if the file does not exist in the specified location.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. This can be a file on the local physical file system or a file on an FTP server.
|
Yes |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
sftpIdentities | The location of the private key. | Optional |
sftpIdentityPassphrase | The passphrase of the private key. | Optional |
Sample configuration
<fileconnector.isFileExist>
<source>{$ctx:source}</source>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
<sftpIdentities>{$ctx:sftpIdentities}</sftpIdentities>
<sftpIdentityPassphrase>{$ctx:sftpIdentityPassphrase}</sftpIdentityPassphrase>
</fileconnector.isFileExist>
Sample request
{
"source":"/home/vive/Desktop/file/test.txt"
}
listFileZip
The listFileZip operation lists all the file paths inside a compressed file. This operation supports the ZIP archive type.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. This can be a file on the local physical file system or a file on an FTP server.
|
Yes |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
Sample configuration
<fileconnector.listFileZip>
<source>{$ctx:source}</source>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
</fileconnector.listFileZip>
Sample request
{
"source":"/home/vive/Desktop/file/test.zip"
}
move
The move operation moves a file or folder from one location to another.
Info: The move operation can only move a file/folder within the same server. For example, you can move a file/folder from one local location to another local location, or from one remote location to another remote location on the same server. You cannot use the move operation to move a file/folder between different servers. If you want to move a file/folder from a local location to a remote location or vice versa, use the copy operation followed by delete operation instead of using the move operation.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. This can be a file on the local physical file system or a file on an FTP server.
|
Yes |
destination | The location where the file has to be moved to. | Yes |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
includeParentDirectory | Set to true if you want to include the parent directory. | Optional |
setAvoidPermission | Set to true if you want to skip the file permission check. | Optional |
sourceSftpIdentities | Location of the source's private key. | Optional |
sourceSftpIdentityPassphrase | Passphrase of the source's private key. | Optional |
targetSftpIdentities | Location of the target's private key. | Optional |
targetSftpIdentityPassphrase | Passphrase of the target's private key. | Optional |
NOTE: The latest File connector (v4.0.7 onwards) supports the decompressing the .gz files.
Sample configuration
<fileconnector.move>
<source>{$ctx:source}</source>
<destination>{$ctx:destination}</destination>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
<filePattern>{$ctx:filePattern}</filePattern>
<includeParentDirectory>{$ctx:includeParentDirectory}</includeParentDirectory>
<setAvoidPermission>{$ctx:setAvoidPermission}</setAvoidPermission>
<sourceSftpIdentities>{$ctx:sftpIdentities}</sourceSftpIdentities>
<sourceSftpIdentityPassphrase>{$ctx:sourceSftpIdentityPassphrase}</sourceSftpIdentityPassphrase>
<targetSftpIdentities>{$ctx:targetSftpIdentities}</targetSftpIdentities>
<targetSftpIdentityPassphrase>{$ctx:targetSftpIdentityPassphrase}</targetSftpIdentityPassphrase>
</fileconnector.move>
Sample request
{
"source":"/home/vive/Desktop/file",
"destination":"/home/vive/Desktop/move",
"filePattern":".*\.txt",
"includeParentDirectory":"true"
}
read
The read operation reads content from an existing file in a specified location.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. This can be a file on the local physical file system or a file on an FTP server.
|
Yes |
filePattern | The pattern of the file to be read. | Yes |
contentType | Content type of the files processsed by the connector. | Yes |
streaming | The streaming mode. This can be either true or false. | Optional |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
includeParentDirectory | Set to true if you want to include the parent directory. | Optional |
sftpIdentities | Location of the private key. | Optional |
sftpIdentityPassphrase | Passphrase of the private key. | Optional |
Info: To enable streaming for large files, you have to add the following message builder and formatter in the
Sample configuration
<fileconnector.read>
<source>{$ctx:source}</source>
<filePattern>{$ctx:filePattern}</filePattern>
<contentType>{$ctx:contentType}</contentType>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
<sftpIdentities>{$ctx:sftpIdentities}</sftpIdentities>
<sftpIdentityPassphrase>{$ctx:sftpIdentityPassphrase}</sftpIdentityPassphrase>
</fileconnector.read>
Sample request
{
"source":"/home/vive/Desktop/file",
"contentType":"application/xml",
"filePattern":".*\.xml",
"streaming":"false"
}
search
The search operation finds a file or folder based on a given file pattern or directory pattern in a specified location.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. This can be a file on the local physical file system or a file on an FTP server.
|
Yes |
filePattern | The pattern of the file to be read. | Yes |
recursiveSearch | Whether you are searching recursively (the possible values are True or False). | Yes |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
includeParentDirectory | Set to true if you want to include the parent directory. | Optional |
Sample configuration
<fileconnector.search>
<source>{$ctx:source}</source>
<filePattern>{$ctx:filePattern}</filePattern>
<recursiveSearch>{$ctx:recursiveSearch}</recursiveSearch>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
</fileconnector.search>
Sample request
{
"source":"/home/vive/Desktop/file",
"filePattern":".*\.xml",
"recursiveSearch":"true"
}
unzip
The unzip operation decompresses zip file. This operation supports ZIP archive type.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. This can be a file on the local physical file system or a file on an FTP server.
|
Yes |
destination | The location of the decompressed file. | Yes |
setTimeout | The timeout value on the JSC (Java Secure Channel) session in milliseconds. E.g., 100000. | Optional |
setPassiveMode | Set to true if you want to enable passive mode. | Optional |
setSoTimeout | The socket timeout value for the FTP client. E.g., 100000. | Optional |
setUserDirIsRoot | Set to true if you want to use root as the user directory. | Optional |
setStrictHostKeyChecking | Sets the requirement to use host key checking. E.g., no. | Optional |
sourceSftpIdentities | Location of the source's private key. | Optional |
sourceSftpIdentityPassphrase | Passphrase of the source's private key. | Optional |
targetSftpIdentities | Location of the target's private key. | Optional |
targetSftpIdentityPassphrase | Passphrase of the target's private key. | Optional |
Sample configuration
<fileconnector.unzip>
<source>{$ctx:source}</source>
<destination>{$ctx:destination}</destination>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
<sourceSftpIdentities>{$ctx:sftpIdentities}</sourceSftpIdentities>
<sourceSftpIdentityPassphrase>{$ctx:sourceSftpIdentityPassphrase}</sourceSftpIdentityPassphrase>
<targetSftpIdentities>{$ctx:targetSftpIdentities}</targetSftpIdentities>
<targetSftpIdentityPassphrase>{$ctx:targetSftpIdentityPassphrase}</targetSftpIdentityPassphrase>
</fileconnector.unzip>
Sample request
{
"source":"/home/vive/Desktop/file/test.zip",
"destination":"/home/vive/Desktop/file/test"
}
ftpOverProxy
The ftpOverProxy operation connects to a FTP server through a proxy.
Parameter Name | Description | Required |
---|---|---|
proxyHost | The host name of the proxy. | Yes |
proxyPort | The port number of the proxy. | Yes |
proxyUsername | The user name of the proxy. | Yes |
proxyPassword | The password of the proxy. | Yes |
ftpUsername | The username of the FTP server. | Yes |
ftpPassword | The password of the FTP server. | Yes |
ftpServer | The FTP server name. | Yes |
ftpPort | The port number of the FTP server. | Yes |
targetPath | The target path. For example, if the file path is ftp://myusername:mypassword@somehost/pub/downloads/testProxy.txt, the targetPath will be pub/downloads/. | Yes |
targetFile | The name of the file (e.g., if the path is like "ftp://myusername:mypassword@somehost/pub/downloads/testProxy.txt", then targetPath will be "testProxy.txt"). | Yes |
keepAliveTimeout | The time to wait between sending control connection keep alive messages when processing file upload or download. | Optional |
controlKeepAliveReplyTimeout | The time to wait for control keep-alive message replies. | Optional |
binaryTransfer | Set the file type to be transferred. | Optional |
localActive | Set the current data connection mode to either ACTIVE_LOCAL_DATA_CONNECTION_MODE or PASSIVE_LOCAL_DATA_CONNECTION_MODE. | Optional |
Sample configuration
<fileconnector.ftpOverProxy>
<proxyHost>{$ctx:proxyHost}</proxyHost>
<proxyPort>{$ctx:proxyPort}</proxyPort>
<proxyUsername>{$ctx:proxyUsername}</proxyUsername>
<proxyPassword>{$ctx:proxyPassword}</proxyPassword>
<ftpUsername>{$ctx:ftpUsername}</ftpUsername>
<ftpPassword>{$ctx:ftpPassword}</ftpPassword>
<ftpServer>{$ctx:ftpServer}</ftpServer>
<ftpPort>{$ctx:ftpPort}</ftpPort>
<targetPath>{$ctx:targetPath}</targetPath>
<targetFile>{$ctx:targetFile}</targetFile>
<keepAliveTimeout>{$ctx:keepAliveTimeout}</keepAliveTimeout>
<controlKeepAliveReplyTimeout>{$ctx:controlKeepAliveReplyTimeout}</controlKeepAliveReplyTimeout>
<binaryTransfer>{$ctx:binaryTransfer}</binaryTransfer>
<localActive>{$ctx:localActive}</localActive>
</fileconnector.ftpOverProxy>
Sample request
{
"proxyHost":"SampleProxy",
"proxyPort":"3128",
"proxyUsername":"wso2",
"proxyPassword":"Password",
"ftpUsername":"primary",
"ftpPassword":"Password",
"ftpServer":"192.168.56.6",
"ftpPort":"21",
"targetFile":"/home/primary/res"
}
send
The send operation sends a file to a specified location.
Parameter Name | Description | Required |
---|---|---|
address | The address where the file has to be sent. | Optional |
append | Set this to true if you want to append the response to the response file. | Optional |
Note: To send a VFS file, you have to specify the following properties in your configuration:
<property name="OUT_ONLY" value="true"/> <property name="ClientApiNonBlocking" value="true" scope="axis2" action="remove"/>
Sample configuration
<fileconnector.send>
<address>{$ctx:address}</address>
<append>{$ctx:append}</append>
</fileconnector.send>
Sample request
{
"address":"/home/vive/Desktop/file/outTest",
"append":"true"
}
getSize
The getSize operation returns the size of a file.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. | Yes |
Sample configuration
<fileconnector.getSize>
<source>{$ctx:source}</source>
</fileconnector.getSize>
Sample request
{
"source":"/home/vive/Desktop/file/outTest/sample.txt"
}
getLastModifiedTime
The getLastModifiedTime operation returns last modified time of a file/folder.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. | Yes |
Sample configuration
<fileconnector.getLastModifiedTime>
<source>{$ctx:source}</source>
</fileconnector.getLastModifiedTime>
Sample request
{
"source":"/home/vive/Desktop/file/outTest/sample.txt"
}
splitFile
The splitFile operation splits a file into multiple chunks.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. | Yes |
destination | The location to write the file. | Yes |
chunkSize | The chunk size in bytes to split the file. This is to split the file based on chunk size. You should provide either chunkSize or numberOfLines to split the file. | Yes |
numberOfLines | The number of lines per file. This is to split the file based on the number of lines. You should provide either chunkSize or numberOfLines to split the file. | Yes |
xpathExpression | Defines a pattern in order to select a set of nodes in XML document. | Yes |
Sample configuration
<fileconnector.splitFile>
<source>{$ctx:source}</source>
<destination>{$ctx:destination}</destination>
<chunkSize>{$ctx:chunkSize}</chunkSize>
<numberOfLines>{$ctx:numberOfLines}</numberOfLines>
<xpathExpression>{$ctx:xpathExpression}</xpathExpression>
</fileconnector.splitFile>
Sample request
{
"source":"/home/vive/Desktop/file/outTest/sample.txt",
"destination":"/home/vive/Desktop/file/outTest/",
"chunkSize":"4096",
"xpathExpression":"//products/product"
}
mergeFiles
The mergeFiles operation merges multiple chunks into a single file.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. | Yes |
destination | The location to write the file. | Yes |
filePattern | The pattern of the file to be read. | Yes |
sourceSftpIdentities | Location of the source's private key. | Optional |
sourceSftpIdentityPassphrase | Passphrase of the source's private key. | Optional |
targetSftpIdentities | Location of the target's private key. | Optional |
targetSftpIdentityPassphrase | Passphrase of the target's private key. | Optional |
Sample configuration
<fileconnector.mergeFiles>
<source>{$ctx:source}</source>
<destination>{$ctx:destination}</destination>
<filePattern>{$ctx:filePattern}</filePattern>
<sourceSftpIdentities>{$ctx:sftpIdentities}</sourceSftpIdentities>
<sourceSftpIdentityPassphrase>{$ctx:sourceSftpIdentityPassphrase}</sourceSftpIdentityPassphrase>
<targetSftpIdentities>{$ctx:targetSftpIdentities}</targetSftpIdentities>
<targetSftpIdentityPassphrase>{$ctx:targetSftpIdentityPassphrase}</targetSftpIdentityPassphrase>
</fileconnector.mergeFiles>
Sample request
{
"source":"/home/vive/Desktop/file/outTest/",
"destination":"/home/vive/Desktop/file/outTest/sample.txt",
"filePattern":"*.txt*"
}
readSpecifiedLines
The readSpecifiedLines operation reads specific lines between given line numbers from a file.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. | Yes |
contentType | Content type of the files processed by the connector. | Yes |
start | Read from this line number. | Yes |
end | Read up to this line number. | Yes |
Sample configuration
<fileconnector.readSpecifiedLines>
<source>{$ctx:source}</source>
<contentType>{$ctx:contentType}</contentType>
<start>{$ctx:start}</start>
<end>{$ctx:end}</end>
</fileconnector.readSpecifiedLines>
Sample request
{
"source":"/home/vive/Desktop/file/outTest/sampleText.txt",
"start":"5",
"end":"25"
}
readALine
The readALine operation reads a specific line from a file.
Parameter Name | Description | Required |
---|---|---|
source | The location of the file. | Yes |
lineNumber | Line number to read. | Yes |
Sample configuration
<fileconnector.readALine>
<source>{$ctx:source}</source>
<lineNumber>{$ctx:lineNumber}</lineNumber>
</fileconnector.readALine>
Sample request
{
"source":"/home/vive/Desktop/file/outTest/sampleText.txt",
"lineNumber":"5"
}
Sample configuration in a scenario¶
The following is a sample proxy service that illustrates how to connect to the File connector and use the create operation to create a file. You can use this sample as a template for using other operations in this category.
Sample Proxy
<proxy xmlns="http://ws.apache.org/ns/synapse"
name="FileConnector_create"
transports="https,http"
statistics="disable"
trace="disable"
startOnLoad="true">
<target>
<inSequence>
<property name="source" expression="json-eval($.source)"/>
<property name="inputContent" expression="json-eval($.inputContent)"/>
<property name="encoding" expression="json-eval($.encoding)"/>
<property name="setTimeout" expression="json-eval($.setTimeout)"/>
<property name="setPassiveMode" expression="json-eval($.setPassiveMode)"/>
<property name="setSoTimeout" expression="json-eval($.setSoTimeout)"/>
<property name="setStrictHostKeyChecking"
expression="json-eval($.setStrictHostKeyChecking)"/>
<property name="setUserDirIsRoot" expression="json-eval($.setUserDirIsRoot)"/>
<fileconnector.create>
<source>{$ctx:source}</source>
<inputContent>{$ctx:inputContent}</inputContent>
<encoding>{$ctx:encoding}</encoding>
<setTimeout>{$ctx:setTimeout}</setTimeout>
<setPassiveMode>{$ctx:setPassiveMode}</setPassiveMode>
<setSoTimeout>{$ctx:setSoTimeout}</setSoTimeout>
<setUserDirIsRoot>{$ctx:setUserDirIsRoot}</setUserDirIsRoot>
<setStrictHostKeyChecking>{$ctx:setStrictHostKeyChecking}</setStrictHostKeyChecking>
</fileconnector.create>
<respond/>
</inSequence>
</target>
<description/>
</proxy>
Note: For more information on how this works in an actual scenario, see File Connector Example.
Top