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 theFTOptixApplication/ProjectFiles/PKI/Own/Certsfolder. If specified, the private key must also be specified. If not specified, it is automatically generated at runtime in theFTOptixApplication/ApplicationFiles/PKI/Own/Certsfolder.
- ClientPrivateKeyFile. Server private key file, with ASCII Base64 encoding and .pem extension. It must be found in theFTOptixApplication/ProjectFiles/PKI/Own/Certsfolder. If specified, the certificate must also be specified. If not specified, it is automatically generated at runtime in theFTOptixApplication/ApplicationFiles/PKI/Own/Certsfolder.
- 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.
- DisconnectFtpClientDisconnects from the FTP server.
- DownloadItem. Downloads a remote item, such as a file or folder that is contained in theremoteItemparameter that exists in theLocalFolderPathfolder. TheoverwriteItemIfExistsparameter 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 thelocalItemPathparameter to theremoteFolderPathfolder. TheoverwriteItemIfExistsparameter 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.derextension. It must be found in theFTOptixApplication/ProjectFiles/PKI/Own/Certsfolder. If specified, the private key must also be specified. If not specified, it is automatically generated at runtime in theFTOptixApplication/ApplicationFiles/PKI/Own/Certsfolder.
- ClientPrivateKeyFile. Server private key file, with ASCII Base64 encoding and.pemextension. It must be found in theFTOptixApplication/ProjectFiles/PKI/Own/Certsfolder. If specified, the certificate must also be specified. If not specified, it is automatically generated at runtime in theFTOptixApplication/ApplicationFiles/PKI/Own/Certsfolder.
- 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;.csvto display only files with.txtand.csvextensions. 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 whenAccessFullFilesystemis 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.- Create the folderC:/FtpServerand inside that folder create the filemyDocument.txt.
- SetC:/FtpServeras the starting folder on the FTP server.
- Configure FTP server parameters such as IP address, port, and authorized users.
- 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. TheOverwriteExistingItemsswitch defines whether an existing file must be overwritten.
- Transfer files. Shows how to connect and disconnect the FTP client using theConnectFTPClientandDisconnectFTPClientmethods and how to download and upload using theDownloadItemandUploadItemmethods.
- Periodic backup method. Allows you to enable periodic downloading of a given file using thePeriodicActionLogicscript. The script is configured withPeriodset at 30 seconds andActionset toDownloadItem. See Download example.
Provide Feedback