I need to zip a set of files from a folder in bucket and download it for the User

I am uploading files in various folders in the bucket “managly”. I need to implement a functionality to zip a set of files (as selected by the User) from a folder in bucket and download the zip file for the User. I tried using “aws-s3-zipper” in Node.js to filter the files from the bucket’s folder and then zip it and download. I get the following error - InvalidAccessKeyId: The AWS Access Key Id you provided does not exist in our records. Kindly guide me and provide me the code in NodeJS to implement the same.

Code :-

var S3Zipper = require ('aws-s3-zipper');

var config ={
      accessKeyId: ACCESS_KEY_ID,
      secretAccessKey: SECRET_ACCESS_KEY,
      bucket: BUCKET

var zipper = new S3Zipper(config);

zipper.filterOutFiles = files; //files is the set of files selected by User

            pipe: res,
            folderName: 'attachments',
            startKey: 'null', // could keep null
            recursive: true
          , function (err, result) {
            if (err)
            else {
              // console.log(result);
              var lastFile = result.zippedFiles[result.zippedFiles.length - 1];
              console.log('lastFile : ', lastFile)
              if (lastFile)
                console.log('last key ', lastFile.Key); // next time start from here
Show comments

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Is there an update on this? I’m trying to do this with Laravel (PHP framework). There are a set of files which I need to zip and give to the user at run time. So, the user uploads a bunch of files and another user shows up to download them. I need to zip and set the download.

Please let me know.

DigitalOcean Spaces was designed to be interoperable with the S3 API in order to allow users to take advantage of existing tooling. In most cases, setting the endpoint to the DigitalOcean region (e.g. will allow Spaces to be a drop-in replacement. Though, in order to do this, the tool must allow configuring that option. Unfortunately, aws-s3-zipper does not expose that yet. I’ve submitted a pull request to add support.

Once it lands, you will be able to configure aws-s3-zipper to use Spaces like so:

var config = {
    endpoint: "",
    region: "nyc3",
    accessKeyId: "MY_SPACES_KEY",
    secretAccessKey: "MY_SPACES_SECRET",
    bucket: 'examplebucket'

var zipper = new S3Zipper(config);