我在 pkgcloud 中使用client.upload来上传文件目录。在所有流完成后如何执行回调?是否有一种内置方法来注册每个流的“完成”事件并在它们全部触发后执行回调?
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);
}