1
0
Fork 0

Add working example

This commit is contained in:
Andrew Tomaka 2017-02-01 10:45:11 -05:00
parent 09a12c9406
commit 6a5f7b64ae
3 changed files with 24 additions and 1 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
node_modules/
hello.txt

View file

@ -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))
})

22
working.js Normal file
View file

@ -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))
})
})