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.
$ npm install s3zip
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
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'
}
*/