s3-multer-uploader
TypeScript icon, indicating that this package has built-in type declarations

1.2.2 • Public • Published

s3-multer-uploader

s3-multer-uploader is a middleware which you can use for uploading the files from your backend to s3 bucket directly. Here you need to provide some required credentials of your AWS ACL account and S3 bucket.

Install

npm i s3-multer-uploader

Usage

const express = require('express');
const { AWSUploader } = require('s3-multer-uploader');
const app = new express();

// Initialize constructor with credentials
const  awsUploader = new  AWSUploader({
    secretAccessKey:  process.env.SECRET_ID,
    accessKeyId:  process.env.ACCESS_ID,
    region:  process.env.REGION,
    bucketName:  process.env.AWS_S3_BUCKET_NAME
})

// for upload a single file 

app.post('/uploadFile',awsUploader.upload().single('file'),(req,res)=>{
res.send({url : req.file.location})
});

// for upload a multiple files together 

app.post('/uploadFile',awsUploader.upload().array('file'),(req,res)=>{
 res.send({urls : req.files.map(item=>item.location)})
});

app.listen(process.env.PORT)

Note - This package uses multer for uploading files

Maintainers

/s3-multer-uploader/

    Package Sidebar

    Install

    npm i s3-multer-uploader

    Weekly Downloads

    0

    Version

    1.2.2

    License

    MIT

    Unpacked Size

    3.89 kB

    Total Files

    4

    Last publish

    Collaborators

    • fullstackrajkumar