1
0
Fork 0

Buffer solution

Works for plain text files (text/html, text), but not css, js files
This commit is contained in:
Andrew Tomaka 2017-02-01 11:17:31 -05:00
parent 5bbe73c403
commit 9ac44cc946

20
buffer.js Normal file
View file

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