I'm using client.upload in pkgcloud to upload a directory of files. How can I execute a callback after all the streams have finished? Is there a built-in way to register each stream's "finish" event and execute a callback after they have all fired?
var filesToUpload = fs.readdirSync("./local_path"); // will make this async
for(let file of filesToUpload) {
var writeStream = client.upload({
container: "mycontainer",
remote: file
});
// seems like I should register finish events with something
writeStream.on("finish", registerThisWithSomething);
fs.createReadStream("./local_path/" + file).pipe(writeStream);
}
async.waterfall()
.The result of one function will be passed to another as a callback arguments.You should check out the documentation of it . – Hepcat