Buffer solution
Works for plain text files (text/html, text), but not css, js files
This commit is contained in:
parent
5bbe73c403
commit
9ac44cc946
1 changed files with 20 additions and 0 deletions
20
buffer.js
Normal file
20
buffer.js
Normal 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))
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue