Add working example
This commit is contained in:
parent
09a12c9406
commit
6a5f7b64ae
3 changed files with 24 additions and 1 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1 +1,2 @@
|
|||
node_modules/
|
||||
hello.txt
|
||||
|
|
2
index.js
2
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))
|
||||
})
|
||||
|
|
22
working.js
Normal file
22
working.js
Normal 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))
|
||||
})
|
||||
})
|
Loading…
Reference in a new issue