-
-
Save pavelloz/91b2d140134635b3c9ad8aaa85549ff7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Also see: https://github.com/pavelloz/streams-vs-buffers