FTP Client configuration

FTP Clients make connections to FTP servers.
Template Libraries
contains a runtime script and a widget that allow you to make connections to FTP servers.

Required packages

See Add NuGet packages and install a stable version of this required NuGet package: FluentFTP.

FTP client script

FTPClientLogic
is a runtime script that exposes OPC UA methods to perform file listing and transfer to and from an FTP server.
Configurable parameters include:
  • FtpServerIPAddress
    . IP address of the FTP server.
  • FtpServerPort
    . FTP server port.
  • FtpServerUsername
    . Username used to authenticate the user on the FTP server.
  • FtpServerUserPassword
    . Password used to authenticate the user on the FTP server.
  • OverwriteFileIfExists
    . Determines whether any existing files must be overwritten or not.
  • ClientCertificateFile
    . Server public certificate file, according to standard X509v3 and with .der extension. It must be found in the
    FTOptixApplication/ProjectFiles/PKI/Own/Certs
    folder. If specified, the private key must also be specified. If not specified, it is automatically generated at runtime in the
    FTOptixApplication/ApplicationFiles/PKI/Own/Certs
    folder.
  • ClientPrivateKeyFile
    . Server private key file, with ASCII Base64 encoding and .pem extension. It must be found in the
    FTOptixApplication/ProjectFiles/PKI/Own/Certs
    folder. If specified, the certificate must also be specified. If not specified, it is automatically generated at runtime in the
    FTOptixApplication/ApplicationFiles/PKI/Own/Certs
    folder.
  • UseFtps
    . Determine protocol to use, FTP or FTPS.
The following parameters, to be used as read-only, expose the internal state of the client:
  • FtpClientIsRunning
    . Indicates if the client is connected to an FTP server.
  • FtpClientOperationInProgress
    . Indicates if the client is running some operations, such as file list or file transfer.
Exposed methods include:
  • ConnectFtpClient
    . Connects to the FTP server.
  • DisconnectFtpClient
    Disconnects from the FTP server.
  • DownloadItem
    . Downloads a remote item, such as a file or folder that is contained in the
    remoteItem
    parameter that exists in the
    LocalFolderPath
    folder.  The
    overwriteItemIfExists
    parameter makes it possible to determine whether any existing files should be overwritten or not.
  • UploadItem
    . Uploads the local item, such as a file or folder that is contained in the
    localItemPath
    parameter to the
    remoteFolderPath
    folder. The
    overwriteItemIfExists
    parameter makes it possible to determine whether any existing files should be overwritten or not.

FTP client widget

FTPClientWidget
allows you to list and transfer files to and from an FTP server through a graphical interface.
Configurable parameters include:
  • ServerIPAddress
    . IP address of the FTP server.
  • FtpServerPort
    . FTP server port.
  • Username
    . Username to authenticate on the FTP server.
  • Password
    . Password of the user to authenticate on the FTP server.
  • ClientCertificateFile
    . Server public certificate file, according to standard X509v3 and with
    .der
    extension. It must be found in the
    FTOptixApplication/ProjectFiles/PKI/Own/Certs
    folder. If specified, the private key must also be specified. If not specified, it is automatically generated at runtime in the
    FTOptixApplication/ApplicationFiles/PKI/Own/Certs
    folder.
  • ClientPrivateKeyFile
    . Server private key file, with ASCII Base64 encoding and
    .pem
    extension. It must be found in the
    FTOptixApplication/ProjectFiles/PKI/Own/Certs
    folder. If specified, the certificate must also be specified. If not specified, it is automatically generated at runtime in the
    FTOptixApplication/ApplicationFiles/PKI/Own/Certs
    folder.
  • UseFtps
    . Determine protocol to use, FTP or FTPS.
  • ExtensionFilter
    . Set s one or more filters to view only files with certain extensions. To specify more than one extension, separate the extension with
    ;
    . For example, use
    .txt;.csv
    to display only files with
    .txt
    and
    .csv
    extensions. Use
    .
    to show files of all extensions.
  • ShowHiddenFiles
    . Specifies whether to show hidden files. This setting does not apply on remote file systems of Windows FTP servers.
  • StartLocalFilesystemPath
    . Specifies the starting folder to browse the local filesystem.
  • AccessFullFilesystem
    . Determines whether to allow full filesystem browsing. This option is only supported for Windows and Ubuntu systems. You can browse from the root of the disks on Windows and from the
    /
    (root) folder on Linux.
  • AccessLocalNetworkDrives
    . Show s the network drives mapped using this setting when
    AccessFullFilesystem
    is enabled in the Windows operating system.

Periodic file transfer via FTP

Use the following steps to combine
FTPClientLogic
and
PeriodicActionLogix
to automate the upload and download of files and folders in a periodic and non-interactive manner. You can use this FTP server configuration to automate file and folder transfers between devices.
  1. Create the folder
    C:/FtpServer
    and inside that folder create the file
    myDocument.txt
    .
  2. Set
    C:/FtpServer
    as the starting folder on the FTP server.
  3. Configure FTP server parameters such as IP address, port, and authorized users.
  4. Start the FTP server.
To use the FTP server that exists in
Template Libraries
, see FTP Server configuration. Then, you must configure the connection parameters to the FTP server in the
FTPClientLogic
script.
The files and folders to be transferred are already configured through
FileTransferDownload
and
FileTransferUpload
.
The pages in the project include:
  • FTP client configuration
    . Allows you to change the configuration parameters of the FTP client. The
    OverwriteExistingItems
    switch defines whether an existing file must be overwritten.
  • Transfer files
    . Shows how to connect and disconnect the FTP client using the
    ConnectFTPClient
    and
    DisconnectFTPClient
    methods and how to download and upload using the
    DownloadItem
    and
    UploadItem
    methods.
  • Periodic backup method
    . Allows you to enable periodic downloading of a given file using the
    PeriodicActionLogic
    script. The script is configured with
    Period
    set at 30 seconds and
    Action
    set to
    DownloadItem
    . See Download example.
Provide Feedback
Have questions or feedback about this documentation? Please submit your feedback here.