Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function removeFiles() {
- return multerHelper.unlinkFiles([
- ...(req?.files?.introVideo || []),
- ...(req?.files?.outroVideo || []),
- ...(req?.files?.questionVideos || []),
- ]);
- }
- try {
- console.log('DATA: ', req.body);
- console.log('FILES: ', req.files);
- const introFile = req?.files?.introVideo[0] || false;
- const outroFile = req?.files?.outroVideo[0] || false;
- const questionFiles = req?.files?.questionVideos || [];
- const result = await api.job.createJob({
- name: req?.body?.name || 'Unnamed',
- interview: {
- intro: introFile ? { fileUpload: null } : null,
- outro: {
- title: req?.body?.outro?.title || undefined,
- description: req?.body?.outro?.description || undefined,
- media: outroFile ? { fileUpload: null } : undefined
- },
- questions: (req?.body?.questions || []).map(question => ({
- ...question//, media: { fileUpload: null }
- })),
- introFile, outroFile, questionFiles
- }
- });
- await removeFiles();
- res.send({ data: result, success: true });
- } catch (err) {
- await removeFiles();
- next(err);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement