Please enable JavaScript to view this site.

Altova FlowForce Server 2022 

Full path: /system/ftp/store

 

Uploads a file to the FTP server.

 

This function returns Boolean TRUE if execution was successful. If the job execution fails, the outcome depends on the value of the Abort on error parameter, as follows:

 

If the Abort on error parameter is TRUE (default value), the job execution is aborted. In this case, you can still handle errors by means of protected blocks (see Handling Step Errors).

If the Abort on error parameter is FALSE, the function returns FALSE.

 

 

Parameters

Name

Type

Description

FTP Server

string

Address of the remote FTP server, either as a URL or IP address.

 

Mandatory parameter.

Port

number

The port number used to connect to the FTP server. The default value is 21.

Directory on host

string

The name of the directory, on the host, where you want to store the file.

 

Optional parameter.

Login credentials

credential

The username and password of the FTP account, as a FlowForce credential record, see Credentials.

 

Skip this parameter if the FTP server does not require credentials.

Use passive mode

boolean

Use passive mode if connection problems occur (for example, if routers or firewalls are set up to prevent active connections).

Use SSL/TLS encryption

string

(Optional parameter, the default value is No.) To transfer information, FTP uses a command channel and a data channel. If you would like to transfer FTP data without encryption, set this value to No. Otherwise, set this value to one of the following:

 

Explicit with encrypted command channel

Explicit with encrypted command and data channel

 

If you set any of the two options above, the server certificate will be validated according to the Verify server certificate parameter described below.

 

Note:Implicit encryption is considered deprecated, and thus not supported in FlowForce.

Verify server certificate

string

(Optional parameter.) Specifies how FlowForce should verify the FTP server's certificate. Valid values:

 

No verification - Accept any certificate.

Verify against system certificate store (default value) - On Windows, use the certificate store of the user account running the job and the system store to verify the certificate signature. On Linux, use the system certificate store, usually located in /usr/lib/ssl/cert.pem and /usr/lib/ssl/certs, or the path where the SSL_CERT_FILE and SSL_CERT_DIR environment variables point to.

Verify against selected server certificate - FlowForce will compare the FTP server's certificate with the one specified in the Server Certificate parameter.

 

Using this parameter requires the presence of a server certificate and a secure connection. If a secure connection cannot be established, the FTP function will fail.

Server certificate

certificate

(Optional parameter.) Specifies the path to a certificate object in FlowForce. The specified FlowForce certificate will be verified against the FTP server certificate if you also set the previous parameter to Verify against selected server certificate. Otherwise, this parameter value will be ignored.

Source file

string

The name of the file to be uploaded to the FTP Server.

 

Mandatory parameter.

Target file

string

The name the file should have once it is uploaded to the FTP Server. This can be different from the Source File.

 

Mandatory parameter.

Abort on error

boolean

This Boolean parameter determines what should be the return value of the function if the job fails. If Abort on error is FALSE, the function will return Boolean FALSE as well. If Abort on error is TRUE, the job execution is aborted. The default value is TRUE.

Working directory

string

Specifies the working directory of the job (for example, c:\somedirectory). If relative paths are used, they will be resolved against the working directory.

Account

string

The FTP account name of the user allowed access to the files on the remote server.

 

Optional parameter.

 

 

Examples

This example shows you how to upload a file to a remote FTP server, without knowing the file name and extension at job configuration time. This is possible by configuring the job to run as a file system trigger, as shown below:

fs_func_ftp_store_01

The trigger above monitors the directory C:\FlowForce\Upload for changes. Whenever you copy a file to this directory, the job fires, and the absolute path of the file that triggered the job becomes available in the triggerfile input parameter. This enables you to use this file in the job without knowing its name and extension, as described below.

fs_func_ftp_store_02

In the job configuration above, the store function is called with the following parameters:

 

FTP Server - The address of the FTP server (an I.P. address, in this example)

Port - The default port 21

Directory on host - In this example, we would like all uploaded files to be put in the "uploads" subdirectory on the server, relative to the FTP root directory.

Login credentials - The FTP username and password required to connect to the FTP server. For the sake of reuse, these were previously defined as credentials and here are just referenced from the public container.

Source file - The path of the local file to be uploaded. In this example, this must be a relative path, because Working directory is set, see below.

Target file - The path of the file on the FTP server after upload. In this example, this must also be a relative path, because Directory on host is set, see below.

Working directory - A directory on the local computer. All local relative file paths are assumed to be relative to this directory. Notice that it is the same as the polling directory defined in the trigger.

 

If Working directory is set, Source file must be a relative, not absolute, path. Likewise, if Directory on host is set, the Target file must be a relative path.

 

This example uses both Working Directory and Directory on host; therefore, we need to convert the absolute path of the triggerfile to relative.

 

To achieve this, Source file uses a FlowForce expression. This expression takes the triggerfile as argument (recall that this is an absolute path), and returns just the file name and extension. For example, if triggerfile is C:\data.txt, the expression would return just data.txt. The same happens with the expression in the Target file. For more details about expressions in FlowForce, see The FlowForce Expression Language.

 

With the configuration above, the following happens whenever you copy a file (regardless of its extension) to the working directory:

 

Assuming that you've copied a file called data.txt, the job fires and gets C:\FlowForce\Upload\data.txt as triggerfile.

Thanks to the expression, Source File becomes data.txt, and so does the Target file.

The actual path of the file to upload is obtained by concatenating the Working directory with the Source File.

The destination path of the file on the server is obtained by concatenating the Directory on host with the Target file.

FlowForce attempts to connect with the supplied FTP credentials. On success, it puts the file data.txt in the uploads directory on the FTP server.

 

© 2016-2022 Altova GmbH