diff --git a/buffer.js b/buffer.js new file mode 100644 index 0000000..db64f65 --- /dev/null +++ b/buffer.js @@ -0,0 +1,20 @@ +const BUCKET = "atomakabucket" + +const unzipper = require("unzipper") +const aws = require("aws-sdk") +aws.config.update({ region: "us-east-1" }) +const s3 = new aws.S3() + +s3 + .getObject({ Bucket: BUCKET, Key: "hello.zip" }) + .createReadStream() + .pipe(unzipper.Parse()) + .on('entry', file => { + file.buffer().then(data => { + s3.putObject( + { Bucket: BUCKET, Key: file.path, Body: data, ACL: "public-read" } + ).promise() + .then(() => console.log("success")) + .catch(err => console.log(err)) + }) + })