Skip to content

Instantly share code, notes, and snippets.

@pavelloz
Created December 1, 2021 20:15
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pavelloz/91b2d140134635b3c9ad8aaa85549ff7 to your computer and use it in GitHub Desktop.
Save pavelloz/91b2d140134635b3c9ad8aaa85549ff7 to your computer and use it in GitHub Desktop.
const { createReadStream } = require("fs");
api
.get({ Bucket, Key })
.createReadStream() // read zip file
.pipe(unzip.Parse())
.on("entry", (entry) => {
// stream it further and use entries inside
if (entry.type !== "Directory") {
const uploadOptions = {
Key: outputKey,
Bucket: Bucket,
Body: entry, // readableStream
ACL: "public-read",
};
return api.upload(uploadOptions).promise();
} else {
entry.autodrain();
}
})
.on("close", () => {
callback(null, "All done!"); // Inform lambda that it can finish execution.
});
@pavelloz
Copy link
Author

pavelloz commented Dec 1, 2021

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment