Table of Contents

Codeunit "SFTP Client"

ID 9762
Namespace: System.SFTPClient

Properties

Name Value
Access Public
InherentEntitlements X
InherentPermissions X

Methods

AddFingerprintSHA256

Adds a SHA256 fingerprint to the list of accepted host key fingerprints.

procedure AddFingerprintSHA256(Fingerprint: Text)

Parameters

Name Type Description
Fingerprint Text

AddFingerprintMD5

Adds an MD5 fingerprint to the list of accepted host key fingerprints.

procedure AddFingerprintMD5(Fingerprint: Text)

Parameters

Name Type Description
Fingerprint Text

Initialize

Initializes the SFTP client with the specified parameters. The client is connected to the server.

procedure Initialize(Hostname: Text, Port: Integer, Username: Text, Password: SecretText): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
Hostname Text

Hostname of the SFTP server

Port Integer

Port of the SFTP server

Username Text

Username for the connection

Password SecretText

Password for the connection

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

Initialize

Initializes the SFTP client with the specified parameters. The client is connected to the server. The private key is used for authentication.

procedure Initialize(HostName: Text, Port: Integer, Username: Text, PrivateKey: InStream): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
HostName Text

Hostname of the SFTP server

Port Integer

Port of the SFTP server

Username Text

Username for the connection

PrivateKey InStream

Private Key for the connection

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

Initialize

Initializes the SFTP client with the specified parameters. The client is connected to the server. The private key is used for authentication and a passphrase is required to decrypt the private key.

procedure Initialize(HostName: Text, Port: Integer, Username: Text, PrivateKey: InStream, Passphrase: SecretText): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
HostName Text

Hostname of the SFTP server

Port Integer

Port of the SFTP server

Username Text

Username for the connection

PrivateKey InStream

Private Key for the connection

Passphrase SecretText

Passphrase to decrypt the private key

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

ListFiles

Lists the files in the specified path on the SFTP server. The result is returned as a list of SFTP File interfaces.

procedure ListFiles(Path: Text, var FileList: List of [Interface "ISFTP File"]): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
Path Text

The path to request

FileList List of [Interface System.SFTPClient."ISFTP File"]

A list that will be populated with ISFTP File interfaces

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

ListFiles

Lists the files in the specified path on the SFTP server. The result is returned as a record of type "SFTP Folder Content".

procedure ListFiles(Path: Text, var FileList: Record "SFTP Folder Content" temporary): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
Path Text

The path to request

FileList Table System.SFTPClient."SFTP Folder Content"

A record that will be populated with file information

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

GetFileAsStream

Downloads a file from the SFTP server and returns it as an InStream.

procedure GetFileAsStream(Path: Text, var InStream: InStream): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
Path Text

Path to the file

InStream InStream

An InStream that will be populated with the file content

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

DeleteFile

Deletes a file on the SFTP server.

procedure DeleteFile(Path: Text): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
Path Text

Path to the file

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

FileExists

Tests if a file exists on the SFTP server.

procedure FileExists(Path: Text, var Result: Boolean): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
Path Text

Path of the file

Result Boolean

Output parameter that will be set to True if the file exists, False otherwise

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

MoveFile

Moves a file from one path to another on the SFTP server.

procedure MoveFile(SourcePath: Text, DestinationPath: Text): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
SourcePath Text

Source path of the file

DestinationPath Text

Destination path of the file

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

Disconnect

Disconnects the SFTP client from the server. This method should be called when the client is no longer needed.

procedure Disconnect()

PutFileStream

Uploads a file to the SFTP server from an InStream.

procedure PutFileStream(Path: Text, var SourceInStream: InStream): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
Path Text

The destination path to upload the file to

SourceInStream InStream

The stream of data to upload

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

GetWorkingDirectory

Returns the working directory of the SFTP client. This is the directory that the client is currently working in.

procedure GetWorkingDirectory(var Result: Text): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
Result Text

Output parameter that will be set to the current working directory path

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

SetWorkingDirectory

Sets the working directory of the SFTP client. This is the directory that the client will work in for subsequent operations.

procedure SetWorkingDirectory(Path: Text): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
Path Text

The new working path of the client

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

IsConnected

Checks if the SFTP client is connected to the server. This method can be used to verify the connection status before performing operations.

procedure IsConnected(): Boolean

Returns

Type Description
Boolean

True if the client is connected, False if the client is disconnected

CreateDirectory

Creates a new directory on the SFTP server.

procedure CreateDirectory(Path: Text): Codeunit "SFTP Operation Response"

Parameters

Name Type Description
Path Text

Path of the directory to create

Returns

Type Description
Codeunit System.SFTPClient."SFTP Operation Response"

A response codeunit containing success/failure status and error information if applicable

See also