From 9ac44cc9461ca924a4c25f565ea00bb414912d42 Mon Sep 17 00:00:00 2001 From: Andrew Tomaka Date: Wed, 1 Feb 2017 11:17:31 -0500 Subject: [PATCH] Buffer solution Works for plain text files (text/html, text), but not css, js files --- buffer.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 buffer.js 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)) + }) + })