add re-execute API
error hundling
This commit is contained in:
parent
395fba645d
commit
c004f6c34f
6 changed files with 99 additions and 93 deletions
|
|
@ -24,30 +24,32 @@ export const fileController = {
|
|||
minutesContent += minutes;
|
||||
return minutesContent;
|
||||
},
|
||||
createZip: async (body: any, outputPath: string, fileName: string) => {
|
||||
console.log(outputPath);
|
||||
await new Promise((resolve, reject) => {
|
||||
const output = fs.createWriteStream(outputPath);
|
||||
const archive = archiver('zip', {
|
||||
zlib: { level: 9 }
|
||||
});
|
||||
createZip: async (body: any, outputPath: string, fileName: string): Promise<boolean> => {
|
||||
try {
|
||||
await new Promise((resolve, reject) => {
|
||||
const output = fs.createWriteStream(outputPath);
|
||||
const archive = archiver('zip', {
|
||||
zlib: { level: 9 }
|
||||
});
|
||||
|
||||
output.on('close', () => {
|
||||
console.log(archive.pointer() + ' total bytes');
|
||||
console.log('archiver has been finalized and the output file descriptor has closed.');
|
||||
resolve(true);
|
||||
});
|
||||
output.on('close', () => {
|
||||
// console.log(archive.pointer() + ' total bytes');
|
||||
// console.log('archiver has been finalized and the output file descriptor has closed.');
|
||||
resolve(true);
|
||||
});
|
||||
|
||||
archive.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
archive.on('error', (err) => {
|
||||
reject(err);
|
||||
});
|
||||
|
||||
archive.pipe(output);
|
||||
archive.append(JSON.stringify(body), { name: fileName + '.json' });
|
||||
archive.finalize();
|
||||
})
|
||||
console.log("ZIP created");
|
||||
return;
|
||||
archive.pipe(output);
|
||||
archive.append(JSON.stringify(body), { name: fileName + '.json' });
|
||||
archive.finalize();
|
||||
})
|
||||
return true;
|
||||
} catch(error) {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
|
||||
};
|
||||
Loading…
Add table
Add a link
Reference in a new issue