Skip to content

Latest commit

 

History

History
53 lines (40 loc) · 1.24 KB

README.md

File metadata and controls

53 lines (40 loc) · 1.24 KB

S3Zip

npm version CircleCI

S3Zip is a lightweight library that creates a zip file from files in a S3 bucket and stores the zip file in the same S3 bucket.

Install

$ npm install s3zip

Usage

zipFiles({keys, bucket, outputFile, s3})

Arguments

  • keys ([string]): an array of S3 keys
  • bucket (string) : an S3 bucket
  • outputFile (string) : the destination key for the zip file on S3
  • s3 (object) : AWS S3 instance

Returns

  • (Promise): Returns a promise of the S3 upload operation

Example

const AWS = require('aws-sdk')
const {zipFiles} = require('s3zip')

zipFiles({
  keys: ['file1.txt', 'file2.txt']),
  bucket: 'some-bucket',
  outputFile: 'files.zip',
  s3: new AWS.S3({accessKeyId, secretAccessKey})
})
.then(console.log)
/*
{
  ETag: '"52344a8de6c541c261b9d2e3bda6fda2"',
  Location: 'https://some-bucket.s3.amazonaws.com/files.zip',
  key: 'files.zip',
  Key: 'files.zip',
  Bucket: 'some-bucket'
}
*/