title: How to create temp files in nodejs
body: <p>I want to attach an xml file and send as email. I have a string of text which I want to write in an xml file. But I don't want to actually create a file every time.</p>
  <p>I am using nodemailer(<a href="https://community.nodemailer.com/using-attachments/" rel="nofollow noreferrer">https://community.nodemailer.com/using-attachments/</a>) to send mail and it supports stream to attach file.</p>
  <p>Does stream mean it has to actually create a file? Can't I just use stream somehow to send it as an attachment without creating a file.</p>
  <p>I have xml string like this which I want to put in an xml file and send email:</p>
  <pre><code>    const xmlStringStart = `&lt;ENVELOPE&gt;
  &lt;HEADER&gt;
    &lt;TALLYREQUEST&gt;Import Data&lt;/TALLYREQUEST&gt;
  &lt;/HEADER&gt;
  &lt;BODY&gt;
    &lt;IMPORTDATA&gt;
      &lt;REQUESTDESC&gt;
        &lt;REPORTNAME&gt;All Masters&lt;/REPORTNAME&gt;
        &lt;STATICVARIABLES&gt;
          &lt;SVCURRENTCOMPANY&gt;X&lt;/SVCURRENTCOMPANY&gt;
        &lt;/STATICVARIABLES&gt;
      &lt;/REQUESTDESC&gt;
      &lt;REQUESTDATA&gt;...`;
  </code></pre>
  <p>I saw PassThrough <a href="https://nodejs.org/api/stream.html#stream_class_stream_passthrough" rel="nofollow noreferrer">https://nodejs.org/api/stream.html#stream_class_stream_passthrough</a> but can't figure out how to use it.</p>