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

lambda-s3-archiver

v1.4.0

Published

This nodejs module will read and archive files in AWS S3 bucket using stream, and store the archive file in S3 as well.

Downloads

894

Readme

lambda-s3-archiver

npm install lambda-s3-archiver --save

Introduction

This nodejs module will read and archive files in AWS S3 bucket using stream, and store the archive file in S3 as well. It works very well archiving any files in S3 bucket. Since it is using stream in both reading the source files and writing the archive file, it can safely process large files without too much memory needed in the lambda.

Description

/*
 * This nodejs module will read and archive files in AWS S3 bucket using stream, and store the archived file in S3 as well..
 * @param {sourceBucket} - the S3 bucket containing the files to archive
 * @param {sourcePath} - the S3 prefix/path containing the files to archive
 * @param {sourceFiles} - (OPTIONAL) the list of filenames in the sourcePath to archive
 *                      - If not specified, all the files in sourcePath will be included in the archive
 * @param {outputFilename} - the filename of the archive file. Default to 'archive'.
 * @param {outputFormat} - the format of the archive file (zip | tar). Default to 'zip'.
 * @param {uploadOptions} - additional options passed to s3.upload https://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/S3.html#upload-property
 * @return {object} - a JSON object containing the details of the archive file.
    {
        s3Bucket: 's3-bucket-name',
        fileKey: 's3-prefix-path/archive.zip',
        fileSize: 1024
    }
 */

Usage

  1. Archive ALL files in the specified s3 sourcePath prefix.
const s3Archiver = require('lambda-s3-archiver');

const result = await s3Archiver.archive('s3-bucket-name', 's3-prefix-path');
console.log(result);
  1. Archive ALL files in the specified s3 sourcePath prefix by passing outputFilename and outputFormat as parameters.
const s3Archiver = require('lambda-s3-archiver');

const result = await s3Archiver.archive('s3-bucket-name', 's3-prefix-path', [], 'outputFile', 'zip');
console.log(result);
  1. Archive specified list of files in the specified s3 sourcePath prefix.
const s3Archiver = require('lambda-s3-archiver');

const result = await s3Archiver.archive('s3-bucket-name', 's3-prefix-path', ['files1', 'files2'], 'outputFile', 'tar');
console.log(result);
  1. Archive ALL files at the s3 root level (bucket name level) by passing outputFilename and outputFormat as parameters.
const s3Archiver = require('lambda-s3-archiver');

const result = await s3Archiver.archive('s3-bucket-name', '', [], 'outputFile', 'zip');
console.log(result);

Important

Please make sure the lambda has read and write access to the source S3 Bucket.

Sample Lambda using the lambda-s3-archiver, with Cloudformation, can be found in https://github.com/francismeynard/aws-journey/tree/master/sample-s3-archiver-service.

Test

npm run test

Releases / Changelogs

1.0.0 - Initial stable release

1.1.0 - Added support for additional s3.upload params

1.2.0 - Fixed issue on archiving ALL files in the S3 prefix/folder where the prefix is included s3.listObjects.

1.3.0 - Added support for path with more than 1000 files.

1.4.0 - Added support to archive at the S3 root level.