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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@voicenter-team/aws-uploader

v1.0.10

Published

The helper that will upload your files to AWS!

Downloads

113

Readme


title: Getting started description: The VoicenterTeam AWS-Uploader is a lightweight and simple utility to upload directories to AWS S3, built specifically for Node.js applications. navigation: title: Getting Started

@voicenter-team/aws-uploader

A lightweight and simple utility to upload directories to AWS S3, built specifically for Node.js applications. It helps to upload your project artifacts, like distribution folders, to S3 with just a few lines of code. This package is built by the Voicenter Team for community use.

Installation

Use the package manager npm to install @voicenter-team/aws-uploader.

npm install @voicenter-team/aws-uploader

Usage

Here is a simple example of using @voicenter-team/aws-uploader:

import { Uploader } from '@voicenter-team/aws-uploader'

const uploader = new Uploader({
    region: 'your-aws-region',
    credentials: {
        accessKeyId: 'your-access-key',
        secretAccessKey: 'your-secret-key'
    }
})

uploader.proceedUploadDirectory(
    'your-bucket-name', 
    './local-directory-path', 
    'target-directory-name'
)
    .then(() => console.log('Upload finished'))
    .catch(err => console.error('Upload error:', err))

Configuration

The Uploader constructor takes an AWSConfig object as parameter:

  • region: AWS region.
  • credentials: Object containing accessKeyId and secretAccessKey.
  • silent: (Optional) If true, the Uploader won't log anything. Default value is true.
  • logger: (Optional) A custom logger object that should have log, error, and warn methods.

Using Custom Logger

You can pass a custom logger to the Uploader constructor. The logger object must have log, error, and warn methods. Here is an example:

import { Uploader } from '@voicenter-team/aws-uploader'

const customLogger = {
    log: (message, ...params) => { /* Custom log implementation */ },
    error: (message, ...params) => { /* Custom error implementation */ },
    warn: (message, ...params) => { /* Custom warn implementation */ }
}

const uploader = new Uploader({
    region: 'your-aws-region',
    credentials: {
        accessKeyId: 'your-access-key',
        secretAccessKey: 'your-secret-key'
    },
    silent: false,
    logger: customLogger
})

By default, Uploader uses the console as the logger. If you pass a custom logger but you want to turn off logging, you can set the silent option to true.

Methods

proceedUploadDirectory

The proceedUploadDirectory method uploads the contents of a local directory to the specified S3 bucket. Returns the Promise with the uploaded folder name

proceedUploadDirectory(bucketName: string, directoryPath: string, targetDir: string): Promise<string>

  • bucketName: The name of the target S3 bucket.
  • directoryPath: The path to the local directory to upload.
  • targetDir: The target directory name in the S3 bucket where the files will be uploaded.

moveFiles

The moveFiles method moves files within an S3 bucket from a source prefix to a target prefix.

moveFilesInS3(bucketName: string, sourcePrefix: string, targetPrefix: string, deleteSource: boolean): Promise<void>

  • bucketName: The name of the S3 bucket.
  • sourcePrefix: The prefix of the source files to move.
  • targetPrefix: The target prefix where the files will be moved to.
  • deleteSource: If to delete the source folder, default false

This method is useful for scenarios where you need to reorganize or archive files within your S3 bucket, such as moving files to a specific folder or prefix.

License

MIT