Skip to content

A simple wrapper of the AWS S3 API for uploading images to S3.

Notifications You must be signed in to change notification settings

seanvm/node-s3-image-uploader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Node.js S3 Image Uploader

Codacy Badge npm version

A simple Node.js wrapper of the AWS SDK for uploading images to S3. This was originally created to assist with uploading images from serverless applications on AWS Lambda to s3.

Installation

Install the package with NPM and add it to your dependencies.

$ npm install node-s3-image-uploader --save

Basic Usage

Include the module.

const Uploader = require('node-s3-image-uploader');

Instantiate the uploader

var uploader = new Uploader(bucketName, options);

The bucketName parameter is a required string containing your DNS-compliant S3 bucket name. The Uploader can also take an optional options object as a param. For example:

var options = {
    filePath: 'images/'
}

var uploader = new Uploader('bucketname.com', options);

You can then call the upload(image, callback) function:

var image = // Must be in base64 format;
var uploader.upload(image, callback);

API

Uploader(string bucketName, {} options)
  • string bucketName - DNS-compliant S3 bucket name (required)
  • object options - configurable upload options (optional)
    • string filePath - folder path to place the image (e.g. 'images/'). This defaults to the root directory of the bucket. There must not be a preceding /. The trailing / is required.

Note

For this package to work correctly, it is assumed that your environment (e.g. AWS Lambda function) is configured with the correct roles to access s3 and perform a putObject action.

License

This package is released under the MIT license. It is simple and easy to understand and places almost no restrictions on what you can do with the code. More Information

About

A simple wrapper of the AWS S3 API for uploading images to S3.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published