1

I have a group of attachments which are to be zipped by js and the zip file should be sent to the user as an attachment.

I am trying to zip the file using archiver.

If I add this zip files to the array of attachments in node mailer the file is corrupted since path is required for node mailer.

Any other way to dynamically create zip files without saving a copy on local or on server which can be reused to send to the client

var zip = Archiver('zip');
  zip.append(file_to_be_zipped, { name: 'file2.txt' })
.finalize();

from: configuration.data.from,
to: req.body.to.join(';'),
cc: req.body.cc && req.body.cc.join(';'),
bcc: req.body.bcc && req.body.bcc.join(';'),
subject: subject,
html: body,
attachments: zip
Matt
  • 68,711
  • 7
  • 155
  • 158
Uma
  • 13
  • 4
  • Archiver creates a stream, that should be able to be [attached](https://nodemailer.com/message/attachments/) as the above answer/docco describes – Matt Jan 04 '23 at 08:52
  • I tried attaching the file but the format is not the zip file the attachment is some non readable file that's getting passed. If we pass a path with the zip file then its working but how to pass a path if the file is dynamic? – Uma Jan 04 '23 at 08:58
  • specify a `filename` that you want the attachment to appear as, and the `content:` is the zip stream from Archiver ? – Matt Jan 04 '23 at 09:04
  • for text files its working of i have to stream a pdf file the data is not in readable format – Uma Jan 04 '23 at 09:12

0 Answers0