0.1.5 • Published 4 years ago

file-upload-s3 v0.1.5

Weekly downloads
2
License
MIT
Repository
github
Last release
4 years ago

AWS S3 IMAGE UPLOAD

An aws s3 image upload package, comes with image compression if you so choose to use this feature

Note: This package is in no way endorsed by AWS, but is a little pet project of mine i wish to make big one day

Install

npm i file-upload-s3
yarn add file-upload-s3

How to use

const express = require('express');
const formidable = require('formidable');

....

const AWS = require('file-upload-s3');
const upload = new AWS.Upload({
    access: '',
    secret: '',
    region: '',
    bucket: ''
});

......

app.post('/upload', async (req, res) => {
    let form = new formidable.IncomingForm();
    form.parse(req, async function(err, fields, files) {
        if (err) {
            console.error(err.message);
            return;
        }
        
        const img = await upload.uploadFile(files.image, false, true) // (a, b, c)

            // a = 'image to be uploaded'
            // b = 'bucket name if you haven't provided it in the initialization earlier
            // c = 'compress, if true, the image would be compressed before sent off to aws s3, 
                false, the image won't be compressed'

        res.json(img)
    });
})

Dev Server

npm run start
yarn start

Production Bundle

npm run build
yarn build

Follow me on Twitter: @devopsjay

0.1.5

4 years ago

0.1.4

4 years ago

0.1.3

4 years ago

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago