# @labeebklatif/s3-up

> S3 upload

Latest version **2.0.2** (published 2022-12-09) · MIT license · 0 weekly downloads

## Install

```sh
npm install @labeebklatif/s3-up
pnpm add @labeebklatif/s3-up
yarn add @labeebklatif/s3-up
bun add @labeebklatif/s3-up
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.2 |
| Published | 2022-12-09 |
| First published | 2022-11-26 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 6.8 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | https://github.com/labeebklatif |
| Maintainers | labeebklatif |
| Keywords | node, aws, s3, upload |

## Links

- npm: https://www.npmjs.com/package/@labeebklatif/s3-up
- Repository: https://github.com/labeebklatif/s3-up
- npm.io page: https://npm.io/package/@labeebklatif/s3-up

## Dependencies (4)

- [glob](https://npm.io/package/glob.md) ^8.0.3
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.1261.0
- [minimatch](https://npm.io/package/minimatch.md) ^5.1.0
- [mime-types](https://npm.io/package/mime-types.md) ^2.1.35

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 2.0.2 (latest) — 2022-12-09
- 2.0.0 — 2022-12-05
- 1.1.5 — 2022-11-27
- 1.1.3 — 2022-11-26
- 1.1.2 — 2022-11-26
- 1.1.1 — 2022-11-26
- 1.1.0 — 2022-11-26
- 1.0.2 — 2022-11-26
- 1.0.1 — 2022-11-26
- 1.0.0 — 2022-11-26

## README

# s3-up

Upload your local files and directories directly to S3 🪣 with NodeJS. Particulary useful if you are having a S3 served website.
This library can be used as part of your build pipeline to deploy new assets. Uploads multiple individual files and directory contents together to a common S3 path.
</br>

## Installation

**npm**

```sh
npm install --save-dev @labeebklatif/s3-up
```

**yarn**

```sh
yarn add --dev @labeebklatif/s3-up
```

## Usage

#### Basic Usage

```js
const Uploader = require("@labeebklatif/s3-up");

const uploader = new Uploader({
  bucket: "s3-bucket-name",
  path: "target-bucket-path",
});

// add individual file
uploader.addFile("path-to-file");

// add all files in a directory
uploader.addDir("path-to-source-dir");

// start upload
uploader.upload();

// Note: all local paths are expected to be relative to the current working directory - process.cwd()
```

</br>

#### Configuration

```js
new Uploader(configuration);
```

`configuration` object can have following properties to control the behavior of the uploader:

⚙️ `bucket` : (String) Name of the bucket of the target S3 bucket.

⚙️ `path` : (String) Path to the target directory in bucket where files should be uploaded.

⚙️ `clean` : (Boolean: true) Indicates whether target directory and contents should be removed before starting upload. Setting this false will skip this feature.

⚙️ `fileProperties` : (Object: {}) key-value pairs that providers additional file properties.
key should be a valid Unix style pattern to match file and value should be an object with additional file properties.

</br>

By default, the library attempts to find matching `ContentType` for each uploaded file using `mime-type` module.
You can override the default properties or assign additional properties for a matching file as follows.
The configuration for first matching key pattern will be used.

```js
uploader.fileProperties: {
  "*.js": {
    ContentType: "text/javascript",
    ContentEncoding: "gzip"
  }
}
```

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