# s3-upload-file

> The **S3Uploader** class is a Node.js module designed to simplify the process of uploading files to Amazon S3. It utilizes the **AWS SDK**, **crypto**, **fs**, and **multer** libraries to provide a convenient interface for handling file uploads to an S3 b

Latest version **1.0.10** (published 2024-02-23) · ISC license · 0 weekly downloads

## Install

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

## 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 | 1.0.10 |
| Published | 2024-02-23 |
| First published | 2023-11-10 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 4 |
| Unpacked size | 8 KB |
| Known vulnerabilities | 0 (+13 in 3 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mukesh Roy |
| Maintainers | itsroy |
| Keywords | s3-uploader, typescript, nodejs, aws-s3, aws-s3-uploader, aws-s3-upload, aws-s3-upload-file, aws-s3-upload-image, aws-s3-upload-video, aws-s3-upload-audio, aws-s3-upload-pdf, aws-s3-upload-doc, aws-s3-upload-docx, aws-s3-upload-xlsx, aws-s3-upload-csv, aws-s3-upload-txt, aws-s3-upload-json, aws-s3-upload-xml, aws-s3-upload-html, aws-s3-upload-css, aws-s3-upload-js, aws-s3-upload-zip, aws-s3-upload-rar, aws-s3-upload-gzip, aws-s3-upload-tar, aws-s3-upload-7z, aws-s3-upload-mp3, aws-s3-upload-mp4, aws-s3-upload-mov, aws-s3-upload-avi, aws-s3-upload-flv, aws-s3-upload-wav, aws-s3-upload-ogg, aws-s3-upload-mpg, aws-s3-upload-mpeg, aws-s3-upload-mkv, aws-s3-upload-3gp, aws-s3-upload-3g2, aws-s3-upload-acc |

## Links

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

## Dependencies (4)

- [fs](https://npm.io/package/fs.md) ^0.0.1-security
- [crypto](https://npm.io/package/crypto.md) ^1.0.1
- [multer](https://npm.io/package/multer.md) ^1.4.5-lts.1
- [aws-sdk](https://npm.io/package/aws-sdk.md) ^2.1493.0

## Alternatives

- [lodash.startswith](https://npm.io/package/lodash.startswith.md) — 769.7K weekly downloads
- [@tarojs/service](https://npm.io/package/@tarojs/service.md) — 33.9K weekly downloads
- [io.extendreality.tilia.indicators.spatialtargets.unity](https://npm.io/package/io.extendreality.tilia.indicators.spatialtargets.unity.md) — 131 weekly downloads
- [@rtarojs/taro](https://npm.io/package/@rtarojs/taro.md) — 90 weekly downloads
- [node-branch-io](https://npm.io/package/node-branch-io.md) — 50 weekly downloads

## Recent versions

- 1.0.10 (latest) — 2024-02-23
- 1.0.9 — 2024-02-23
- 1.0.8 — 2024-02-23
- 1.0.7 — 2023-11-13
- 1.0.6 — 2023-11-13
- 1.0.5 — 2023-11-13
- 1.0.4 — 2023-11-13
- 1.0.3 — 2023-11-13
- 1.0.2 — 2023-11-13
- 1.0.1 — 2023-11-13
- 1.0.0 — 2023-11-10

## README

# **S3Uploader Documentation**

The **S3Uploader** class is a Node.js module designed to simplify the process of uploading files to Amazon S3. It utilizes the **AWS SDK**, **crypto**, **fs**, and **multer** libraries to provide a convenient interface for handling file uploads to an S3 bucket.

## Installation

To use the **S3Uploader** class, you need to install the required dependencies. Use the following command:

```bash
npm install aws-sdk crypto fs multer



**License**
This project is licensed under the MIT License - see the LICENSE file for details.


const { S3Uploader } = require('s3-upload-file');

// Initialize S3Uploader with your AWS credentials and S3 bucket information
const s3Uploader = new S3Uploader('*your-access-key-id*', '*your-secret-access-key*', '*your-region*', '*your-bucket-name*');

// Middleware for handling file uploads (use with Express or similar frameworks)
const uploadMiddleware = s3Uploader.uploadMiddleware();

// Example route for handling file uploads
app.post('/upload', uploadMiddleware, (req, res) => {
  s3Uploader.uploadFile(req)
    .then((url) => {
      res.json({ success: true, url });
    })
    .catch((error) => {
      console.error('File upload error:', error);
      res.status(500).json({ success: false, error: 'File upload failed' });
    });
});

API Reference


S3Uploader

new S3Uploader(accessKeyId, secretAccessKey, region, bucketName)

Creates an instance of the S3Uploader class.

accessKeyId: AWS access key ID.
`secretAccessKey**: AWS secret access key.
`region**: AWS region.
`bucketName**: The name of the S3 bucket.

uploadMiddleware()


uploadMiddleware(): Function



uploadFile(req: Object): Promise<string>



Uploads a file to the specified S3 bucket.

req: The request object containing the file information.
Returns a Promise that resolves with the S3 file URL.


Examples
For more examples and detailed usage, check out the examples directory.

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