I am trying to sequentially archive (using node-archiver) a couple of remote files fetched using bent:
const appendTracks = async (archive, items) => {
items.forEach(async (item) => {
const beatStream = await bent(item.publicUrl)(); // mp3s **
archive.append(beatStream, { name: item.name });
// ********** the following doesn't seem to work ****************
await new Promise((resolve, reject) => {
beatStream.on('end', () => { // is this even possible ??? 🤷🏻♂️
resolve();
});
beatStream.on('error', (err) => {
reject();
});
});
});
};
archive.pipe(res);
appendTracks(archive, order.items).then(() => archive.finalize());
How do I ensure one stream is done before the next download begins?
Need to guarantee that archive.finalize() isn't fired prematurely, which is what is happening right now.
I am trying to sequentially archive (using node-archiver) a couple of remote files fetched using bent:
How do I ensure one stream is done before the next download begins?
Need to guarantee that
archive.finalize()isn't fired prematurely, which is what is happening right now.