7596-devToTest_2426 #2600
|
@ -41,14 +41,16 @@ module.exports = Self => {
|
|||
if (typeof options == 'object')
|
||||
Object.assign(myOptions, options);
|
||||
|
||||
ids = ids.split(',');
|
||||
|
||||
for (const id of ids) {
|
||||
const downloadAddZip = async id => {
|
||||
ctx.args = ctx.args || {};
|
||||
ctx.args.id = Number(id);
|
||||
const [data] = await models.Route.cmr(ctx, myOptions);
|
||||
zip.file(`${id}.pdf`, data, {binary: true});
|
||||
}
|
||||
};
|
||||
|
||||
ids = ids.split(',');
|
||||
const promises = ids.map(id => downloadAddZip(id));
|
||||
await Promise.all(promises);
|
||||
const zipStream = zip.generateNodeStream({streamFiles: true});
|
||||
return [zipStream, 'application/zip', `filename="cmrs.zip"`];
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue