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 🙏

© 2026 – Pkg Stats / Ryan Hefner

simple-s3-upload-util

v1.0.1

Published

A simple utility to upload files to AWS S3

Downloads

6

Readme

Simple S3 Upload Util

A simple and lightweight utility for uploading files to AWS S3 with environment variable configuration.

Installation

npm install simple-s3-upload-util

Setup

  1. Create a .env file in your project root:
AWS_ACCESS_KEY_ID=your_access_key_here
AWS_SECRET_ACCESS_KEY=your_secret_key_here
AWS_REGION=us-east-1
AWS_BUCKET_NAME=your-bucket-name
  1. Make sure to add .env to your .gitignore file to keep your credentials secure.

Usage

Basic Usage

const SimpleS3UploadUtil = require('simple-s3-upload-util');

// Initialize with environment variables
const uploader = new SimpleS3UploadUtil();

// Upload a single file
async function uploadExample() {
  const result = await uploader.uploadFile('./path/to/your/file.jpg');
  console.log(result);
}

uploadExample();

Advanced Usage

const SimpleS3UploadUtil = require('simple-s3-upload-util');

// Initialize with custom options (overrides .env)
const uploader = new SimpleS3UploadUtil({
  region: 'us-west-2',
  bucketName: 'my-custom-bucket'
});

// Upload with custom S3 key
const result = await uploader.uploadFile('./image.jpg', 'uploads/my-image.jpg');

// Upload with additional S3 options
const result = await uploader.uploadFile('./file.pdf', 'documents/file.pdf', {
  ServerSideEncryption: 'AES256',
  Metadata: {
    'uploaded-by': 'my-app'
  }
});

Upload Multiple Files

const files = [
  { filePath: './image1.jpg', key: 'images/image1.jpg' },
  { filePath: './document.pdf', key: 'docs/document.pdf' },
  { filePath: './data.json' } // Uses filename as key
];

const results = await uploader.uploadFiles(files);
console.log(results);

API Reference

Constructor

new SimpleS3UploadUtil(options)

Options:

  • region (string): AWS region (default: process.env.AWS_REGION or 'us-east-1')
  • accessKeyId (string): AWS access key (default: process.env.AWS_ACCESS_KEY_ID)
  • secretAccessKey (string): AWS secret key (default: process.env.AWS_SECRET_ACCESS_KEY)
  • bucketName (string): S3 bucket name (default: process.env.AWS_BUCKET_NAME)

Methods

uploadFile(filePath, key?, options?)

Upload a single file to S3.

Parameters:

  • filePath (string): Local path to the file
  • key (string, optional): S3 key for the file. Defaults to filename
  • options (object, optional): Additional S3 PutObject parameters

Returns: Promise resolving to upload result object

uploadFiles(files, options?)

Upload multiple files to S3.

Parameters:

  • files (array): Array of file objects { filePath, key? }
  • options (object, optional): Additional S3 PutObject parameters

Returns: Promise resolving to array of upload results

setBucket(bucketName)

Change the target S3 bucket.

Parameters:

  • bucketName (string): New bucket name

Response Format

Successful upload:

{
  success: true,
  key: "uploads/file.jpg",
  bucket: "my-bucket",
  location: "https://my-bucket.s3.us-east-1.amazonaws.com/uploads/file.jpg",
  etag: "\"abc123...\"",
  versionId: "version123" // Only if versioning is enabled
}

Failed upload:

{
  success: false,
  error: "Error message"
}

Requirements

  • Node.js 14+
  • AWS S3 bucket with appropriate permissions
  • AWS credentials with S3 upload permissions

License

MIT