npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

aws-s3-classes

v1.0.3

Published

ES6 classes for common S3 calls. Promise enabled.

Downloads

5

Readme

#AWS S3 Classes A set of promise enabled, ES6 Classes for applying common AWS S3 methods.

Inline docsnpm version

##Class and Method Summary Class | Methods Supported --------|--------------------- Copy | copyObject Del | deleteObject, deleteObjects Get | getObject, getObjects*, writeObjectToLocalFile* List | listObjects** Put | writeObjectFromLocalFile*

* Not available from AWS S3

** Available from AWS S3, but highly augmented

##Synopsis

Retrieve a list of S3 objects into memory:

let s3 = require('aws-sdk').S3();
let Get = require('aws-s3-classes').Get;
let getConfig = [
    {Bucket: 'bucket', Key: 'object1', 
    {Bucket: 'bucket', Key: 'object2'}
];

// Call the getObjects method to retrieve the objects given into memory. 
// Notice the second parm is the number of parallel threads to use. 
// Use a value of 1 to get the objects serially.
new Get(s3).getObjects(getConfig, 2)
    .then( (results) => {
        console.log(results); 
        // We'll get back an array of 2 objects, assuming they were found
        /*
        [   {Bucket: 'bucket', Key: 'object1', Body: <buffer> ...},
            {Bucket: 'bucket', Key: 'object2', Body: <buffer> ...}]
        */    
    });

Write an S3 object to a local file

let s3 = require('aws-sdk').S3();
let Get = require('aws-s3-classes').Get;
let getConfig = {Bucket: 'bucket', Key: 'object1'};

// Write the data in the given S3 object to a local file
new Get(s3).writeObjectToLocalFile(getConfig, 'my-filename.txt')
    .then( (results) => {
        console.log(results); 
        // The file will be written and results will contain: 
        /*
        {Config: {Bucket: 'bucket', Key: 'object1'}, 
        Filename: 'my-filename.txt'};
        */    
    });

Write a local file to an S3 object

let s3 = require('aws-sdk').S3();
let Put = require('aws-s3-classes').put;
let putConfig = {Bucket: 'bucket', Key: 'object1'};

// Write the contents of a local file to an S3 Object
new Put(s3).writeObjectFromLocalFile(getConfig, 'my-filename.txt')
    .then( (results) => {
        console.log(results); 
        // The object will be created. Sample results object below: 
        /*
        { ETag: '"0b3410642200aa8ca4515c53f16201dc"',
          Bucket: 'bucket',
          Key: 'object1' }
        */    
    });

##Description These classes exist to simplify the code used for some commonly used AWS S3 functions. Some of the methods are boilerplate S3, but many add considerable value to the stock calls.

Here are the value-add highlights:

  • Get and Put include streaming file handling
  • List uses a generator to call listObjectsV2 multiple times, to fulfill the request.
  • Get.getObjects allows the user to combine serial and parallel calls.

The last item is probably the most interesting implementation. It allows the user to get multiple objects in one shot and control the number of threads used. This is very convenient when you have a large list of small objects that you want to retrieve to memory.

##Project Features

  • ES6 Class
  • Promise enabled
  • Complete test coverage with Mocha and Chai
  • JSDoc generated API documentation

##Installation npm install aws-s3-classes --save

Git Repository: https://github.com/wildbillh/aws-s3-classes

##Documentation API Documentation: aws-s3-classes