diff --git a/.gitignore b/.gitignore index c2658d7..cef579b 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ node_modules/ +hello.txt diff --git a/index.js b/index.js index 10d8175..312f9b0 100644 --- a/index.js +++ b/index.js @@ -11,6 +11,6 @@ s3 .pipe(unzipper.Parse()) .on('entry', file => { s3.putObject({ Bucket: BUCKET, Key: file.path, Body: file }).promise() - .then(() => console.log("then")) + .then(() => console.log("success")) .catch(err => console.log(err)) }) diff --git a/working.js b/working.js new file mode 100644 index 0000000..6c5a7f3 --- /dev/null +++ b/working.js @@ -0,0 +1,22 @@ +const BUCKET = "atomakabucket" + +const fs = require("fs") +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.pipe(fs.createWriteStream(file.path)) + .on('finish', () => { + s3.putObject( + { Bucket: BUCKET, Key: file.path, Body: fs.createReadStream(file.path) } + ).promise() + .then(() => console.log("success")) + .catch(err => console.log(err)) + }) + })