# s3-upload-helper

> ---

Latest version **1.2.0** (published 2022-06-02) · ISC license · 0 weekly downloads

## Install

```sh
npm install s3-upload-helper
pnpm add s3-upload-helper
yarn add s3-upload-helper
bun add s3-upload-helper
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.0 |
| Published | 2022-06-02 |
| First published | 2022-05-25 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 6.4 KB |
| Known vulnerabilities | 0 (+15 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | MD ASIF JAWED |
| Maintainers | mdasifj625 |
| Keywords | s3, upload-helper |

## Links

- npm: https://www.npmjs.com/package/s3-upload-helper
- Repository: https://github.com/SoluLab/s3-upload-helper
- Homepage: https://github.com/SoluLab/s3-upload-helper#readme
- Issues: https://github.com/SoluLab/s3-upload-helper/issues
- npm.io page: https://npm.io/package/s3-upload-helper

## Dependencies (4)

- [sharp](https://npm.io/package/sharp.md) ^0.30.5
- [multer](https://npm.io/package/multer.md) ^1.4.4
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.1142.0
- [multer-s3](https://npm.io/package/multer-s3.md) ^2.10.0

## Alternatives

- [lodash.assign](https://npm.io/package/lodash.assign.md) — 2.3M weekly downloads
- [lodash.chunk](https://npm.io/package/lodash.chunk.md) — 1.8M weekly downloads
- [react-native-ios-utilities](https://npm.io/package/react-native-ios-utilities.md) — 138.5K weekly downloads
- [@technically/lodash](https://npm.io/package/@technically/lodash.md) — 50.9K weekly downloads
- [@fluid-topics/ft-icon](https://npm.io/package/@fluid-topics/ft-icon.md) — 20.6K weekly downloads

## Recent versions

- 1.2.0 (latest) — 2022-06-02
- 1.1.2 — 2022-06-02
- 1.1.1 — 2022-06-02
- 1.1.0 — 2022-05-30
- 1.0.1 — 2022-05-25
- 1.0.0 — 2022-05-25

## README

# <center>S3 Uplod Library</center>
---

## Install
---

<strong>To use the package, just do the standard</strong>

    $ npm install --save s3-upload-helper


## Startup
---

* <strong>CommonJS</strong>

```js

var S3Helper = require('s3-upload-helper');

var s3 = new S3Helper('accessId', 'secretKey', 's3BucketName', 's3Region');

```
* ESM

```js

import S3Helper  from 's3-upload-helper';

const s3 = new S3Helper('accessId', 'secretKey', 's3BucketName', 's3Region');

```

## Usage
---

* <strong>uploadFileS3</strong>

```js
/* It Returns a Multer instance that provides several methods for generating middleware, that process files uploaded in multipart/form-data format.

* in the example below i have used .array() function that returns array or files in req.files

* you can use other functions like .any, .fields .none and .single

* all these functions returns a middleware that will process your file upload

* all these functions returns uploaded file in different way you can go through multer docs for that

* pass fileName inside req body for naming your file 

* if not passed, file name would be "File/File-current_time.extension"

* file will be available on req.files as array of fles

*/
router.post('/upload-file', s3.uploadFileS3.array('file'), (req, res) => {
	const file = req.files; // Array of files
	if (file) {
		return res.status(200).send({ data: file });
	}
	res.status(500).send({ errMsg: 'Something went wrong, file not uploaded' });
});

```

* <strong>S3ExtractMeta</strong>

```js

router.post('/extract-file-metadata', (req, res) => {
	// pass file as array of objects
	const file = req.files;
	const metaData = s3.S3ExtractMeta(file);
	if (metaData) {
		return res.status(200).send({ data: metaData });
	}

	res.status(500).send({
		errMsg: 'Something went wrong',
	});
});

```

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