Last active
November 26, 2019 16:26
-
-
Save RizkyRajitha/721ce1f1e8f6ed0a9f368c3de821a3da to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var files = req.files; | |
var promisarr = [];//initialize promises array | |
function multiplefiles3(resobj) { | |
console.log(resobj.originalname); | |
var params = { | |
Bucket: "******", | |
Key: resobj.originalname, | |
Body: resobj.buffer | |
}; | |
return s3bucket.upload(params).promise(); | |
} | |
var uploadsize = 0; | |
files.map(file => { | |
uploadsize = uploadsize + file.size; | |
promisarr.push(multiplefiles3(file));//push individual promises to that array , i'll refer them as child promises | |
}); | |
Promise.all(promisarr)//evoke Promise.all() function , i'll refer this as parent promise | |
.then(result => { | |
//this result is a array of objects from the fulfiled promise | |
}) | |
.catch(err => console.log(err));//if any of those promises get reject this whole promise will be rejected | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment