basic-sftp
v0.1.2
Published
🤹🏻♀️ A basic promise-based SFTP Client
Downloads
183
Maintainers
Readme
Install
npm i basic-sftp
Usage
Import
ES Modules
import { Client } from 'basic-sftp';
CommonJS
const { Client } = require('basic-sftp');
Connect
const sftp = new Client();
await sftp.connect({
host: '',
port: 22,
username: '',
password: '',
});
- The connection access extends all the
ssh2
options
Reconnect
await sftp.reconnect();
Close Connection
await sftp.end();
Methods
ls
Lists the contents of a directory
await sftp.ls(path);
is
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
ensureDir
Creates the path recursively, if it does not exist
await sftp.ensureDir(path);
uploadFile
Uploads a local file to the remote server
await sftp.uploadFile(localPath, remotePath);
downloadFile
Downloads a remote file to the local workspace
await sftp.downloadFile(remotePath, localPath);
unlink
Remove all files and directories from a directory, including the directory itself, if it exists
await sftp.unlink(path);
getConnection
Brings up the original
ssh2.sftp
methodssftp.getConnection();
- [ ] Features
- [x]
ls
- [x]
is
- [x]
ensureDir
- [x]
unlink
- [x]
uploadFile
- [x]
downloadFile
- [ ]
uploadDir
- [ ]
downloadDir
- [x]
Credits
| Contributions | GitHub | | ------------- | ---------------------------------------------------------------------------------- | | Author | |