Class: ScpClient
A connected client. Create one with connect, close it with ScpClient.close or await using.
Properties
| Property | Modifier | Type | Description |
|---|---|---|---|
fs | readonly | RemoteFs | undefined | Remote filesystem operations. undefined when the connection uses SCP. |
protocol | readonly | ActiveProtocol | The protocol transfers use on this connection. |
remoteOs | readonly | RemoteOs | Path flavour and quoting rules of the server, as passed to connect. |
sftp | readonly | SFTPWrapper | undefined | The raw ssh2 SFTP session, for advanced use. undefined when the connection uses SCP. |
ssh | readonly | Client | The underlying ssh2 client, for advanced use such as running commands. |
Accessors
closed
Get Signature
get closed(): boolean;true once the connection is closed, by close or by the network.
Returns
boolean
Methods
[asyncDispose]()
asyncDispose: Promise<void>;Closes the connection at the end of an await using block.
Returns
Promise<void>
close()
close(): Promise<void>;Closes the connection. Safe to call more than once.
Returns
Promise<void>
download()
download(
remotePath,
localPath,
options?
): Promise<TransferResult>;Copies a remote file, or a directory with recursive: true, to localPath. The destination is exact and local parent directories are created.
Parameters
| Parameter | Type |
|---|---|
remotePath | string |
localPath | string |
options | TransferOptions |
Returns
Promise<TransferResult>
readFile()
readFile(remotePath, options?): Promise<Buffer<ArrayBufferLike>>;Reads a whole remote file into memory. Works over SFTP and SCP.
Parameters
| Parameter | Type |
|---|---|
remotePath | string |
options | ReadFileOptions |
Returns
Promise<Buffer<ArrayBufferLike>>
upload()
upload(
localPath,
remotePath,
options?
): Promise<TransferResult>;Copies a local file, or a directory with recursive: true, to remotePath. The destination is exact: upload('dist', '/www') makes /www mirror dist. The remote parent directory must exist.
Parameters
| Parameter | Type |
|---|---|
localPath | string |
remotePath | string |
options | TransferOptions |
Returns
Promise<TransferResult>
writeFile()
writeFile(
remotePath,
data,
options?
): Promise<void>;Writes a string, bytes or a stream to a remote file. Works over SFTP and SCP.
Parameters
| Parameter | Type |
|---|---|
remotePath | string |
data | string | Uint8Array<ArrayBufferLike> | Readable |
options | WriteFileOptions |
Returns
Promise<void>