# basic-sftp

> 🤹🏻‍♀️ A basic promise-based SFTP Client

Latest version **0.1.2** (published 2023-04-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install basic-sftp
pnpm add basic-sftp
yarn add basic-sftp
bun add basic-sftp
```

## Health

**Score 20/100 (F)** — status: abandoned.

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.2 |
| Published | 2023-04-08 |
| First published | 2023-01-11 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=14.18.0 \|\| >=16.0.0 |
| Dependencies | 2 |
| Unpacked size | 25.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | https://github.com/wellwelwel |
| Maintainers | weslley.io |
| Keywords | sftp, client, upload, download, promise, promises, remote |

## Links

- npm: https://www.npmjs.com/package/basic-sftp
- Repository: https://github.com/wellwelwel/basic-sftp
- Homepage: https://github.com/wellwelwel/basic-sftp#readme
- Issues: https://github.com/wellwelwel/basic-sftp/issues
- npm.io page: https://npm.io/package/basic-sftp

## Dependencies (2)

- [ssh2](https://npm.io/package/ssh2.md) ^1.11.0
- [@types/ssh2](https://npm.io/package/@types/ssh2.md) ^1.11.9

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 0.1.2 (latest) — 2023-04-08
- 0.1.1 — 2023-01-11
- 0.1.0 — 2023-01-11

## README

<h2 align="center">Basic SFTP</h2>
<p align="center">🤹🏻‍♀️ A basic promise-based SFTP Client</p>

## Install

```shell
   npm i basic-sftp
```

<hr />

### Usage

#### Import

-  ES Modules

   ```javascript
   import { Client } from 'basic-sftp';
   ```

-  CommonJS

   ```javascript
   const { Client } = require('basic-sftp');
   ```

<hr />

#### Connect

```javascript
const sftp = new Client();

await sftp.connect({
   host: '',
   port: 22,
   username: '',
   password: '',
});
```

-  The connection access extends all the [`ssh2`](https://github.com/mscdex/ssh2) options

#### Reconnect

```javascript
await sftp.reconnect();
```

#### Close Connection

```javascript
await sftp.end();
```

<hr />

### Methods

#### ls

-  Lists the contents of a directory

   ```javascript
   await sftp.ls(path);
   ```

#### is

-  Get the type from path: `File | Directory | null`

   ```javascript
   await sftp.is(path);
   ```

   -  `File` means that the remote path is a **file**
   -  `Directory` means that the remote path is a **directory**
   -  `null` means that the remote path **doesn't exist**

#### ensureDir

-  Creates the path recursively, if it does not exist

   ```javascript
   await sftp.ensureDir(path);
   ```

#### uploadFile

-  Uploads a local file to the remote server

   ```javascript
   await sftp.uploadFile(localPath, remotePath);
   ```

#### downloadFile

-  Downloads a remote file to the local workspace

   ```javascript
   await sftp.downloadFile(remotePath, localPath);
   ```

#### unlink

-  Remove all files and directories from a directory, including the directory itself, if it exists

   ```javascript
   await sftp.unlink(path);
   ```

#### getConnection

-  Brings up the original [`ssh2.sftp`](https://github.com/mscdex/ssh2/blob/master/SFTP.md) methods

   ```javascript
   sftp.getConnection();
   ```

<hr />

-  [ ] Features
   -  [x] [`ls`](./src/functions/ls.ts)
   -  [x] [`is`](./src/functions/is.ts)
   -  [x] [`ensureDir`](./src/functions/ensureDir.ts)
   -  [x] [`unlink`](./src/functions/unlink.ts)
   -  [x] [`uploadFile`](./src/functions/uploadFile.ts)
   -  [x] [`downloadFile`](./src/functions/downloadFile.ts)
   -  [ ] `uploadDir`
   -  [ ] `downloadDir`

<hr />

### Credits

| Contributions | GitHub                                                                             |
| ------------- | ---------------------------------------------------------------------------------- |
| Author        | [![wellwelwel](./.github/assets/readme/author.svg)](https://github.com/wellwelwel) |

---
_Source: https://npm.io/package/basic-sftp · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
