Skip to main content

FTP

In order to interact with an FTP server use the FTP module. It allows you to upload files, send data, and set authentication details using private keys.

SFTPClient​

Use the SFTPClient class to access this features.

Constructor​

Create a new SFTP Client instance with a specified host URL.

new SFTPClient(url: string);

Methods​

sendData()​

Creates a file with encoded data on the SFTP server.

sendData(dstPath: string, encodedData: string): Promise<void>;

sendLocalFile()​

Uploads a local file to the SFTP server. dstPath is the path on the server, and srcPath is the local file path.

sendLocalFile(dstPath: string, srcPath: string): Promise<void>;

sendImage()​

Uploads an image to the SFTP server. dstPath is the path on the server. The extension of dstPath defines the encoding format of the image.

sendImage(dstPath: string, image: Image): Promise<void>;

setPrivateKeyFromFile()​

Sets the private key from a file and a passphrase.

setPrivateKeyFromFile(keyFilepath: string, passphrase: string): Promise<void>;

Properties​

host​

Host of the SFTP server.

host: string;

port​

Port of the SFTP server. Defaults to 22.

port: number;

user​

User of the SFTP server.

user: string;

password​

Password of the SFTP server.

password: string;

privateKey​

Private key of the SFTP server.

privateKey: string;

passphrase​

Passphrase of the SFTP server.

passphrase: string;