🤹🏻♀️ A basic promise-based SFTP Client
npm i basic-sftp
-
ES Modules
import { Client } from 'basic-sftp';
-
CommonJS
const { Client } = require('basic-sftp');
const sftp = new Client();
await sftp.connect({
host: '',
port: 22,
username: '',
password: '',
});
- The connection access extends all the
ssh2
options
await sftp.reconnect();
await sftp.end();
-
Lists the contents of a directory
await sftp.ls(path);
-
Get the type from path:
File | Directory | null
await sftp.is(path);
File
means that the remote path is a fileDirectory
means that the remote path is a directorynull
means that the remote path doesn't exist
-
Creates the path recursively, if it does not exist
await sftp.ensureDir(path);
-
Uploads a local file to the remote server
await sftp.uploadFile(localPath, remotePath);
-
Downloads a remote file to the local workspace
await sftp.downloadFile(remotePath, localPath);
-
Remove all files and directories from a directory, including the directory itself, if it exists
await sftp.unlink(path);
-
Brings up the original
ssh2.sftp
methodssftp.getConnection();
- Features
-
ls
-
is
-
ensureDir
-
unlink
-
uploadFile
-
downloadFile
-
uploadDir
-
downloadDir
-
Contributions | GitHub |
---|---|
Author |