Skip to main content

sftpLs()

Lists the files and directories in the specified path using SFTP.

Signature

Parameters

string
required
The path to list on the remote server.
CallbackFunction<LsResult[]>
Optional callback function to handle the result asynchronously.

Returns

Promise<LsResult[]>
A promise that resolves to an array of LsResult objects representing the files and directories in the specified path.

LsResult Type

string
The name of the file or directory.
boolean
Whether the item is a directory (true) or a file (false).
string
The last modification date of the file or directory.
string
The last access date of the file or directory.
number
The size of the file in bytes. For directories, this may be 0 or the block size.
number
The user ID of the file or directory owner.
number
The group ID of the file or directory owner.
number
File permission flags.

Example


sftpMkdir()

Creates a directory on the remote server using SFTP.

Signature

Parameters

string
required
The path of the directory to create on the remote server.
CallbackFunction<void>
Optional callback function to handle the result.

Returns

Promise<void>
A promise that resolves when the directory is created successfully, or rejects with an error if the operation fails.

Example


sftpRmdir()

Removes a directory on the remote server using SFTP.
The directory must be empty before it can be removed. If the directory contains files or subdirectories, the operation will fail.

Signature

Parameters

string
required
The path of the directory to remove on the remote server.
CallbackFunction<void>
Optional callback function to handle the result or error.

Returns

Promise<void>
A promise that resolves when the directory is successfully removed, or rejects with an error if the operation fails.

Example

Last modified on March 26, 2026