title: axios file download and storing leads in a corrupt file (encoding problem)?
body: <p>I have a typical JPG file that I download using <code>axios</code> and store on a disk like so:</p>
  <pre><code>// Just create axios instance that does not care about HTTPS certificate validity
  // since I need to download from an untrusted internal service. 
  // Included for completeness. Do not borrow this bit unless you know what you are doing. 
  const axiosInstance = axios.create({
      httpsAgent: new https.Agent({
          rejectUnauthorized: false
      })
  });
  // Download file
  fileData = await axiosInstance.get(imageUrl, {
      responseType: 'arraybuffer',
  
  });
  console.log(`Dowloaded OK, size ${fileData.data.length} bytes`));
  // Dump file to disk
  await fs.writeFile(`${filename}`, fileData.data, (err) =&gt; {}
  });
  </code></pre>
  <p>I observe that while console.log reports correct number of bytes and <code>fileData.data</code> looks OK in debugger, the file recorded has twice as many bytes and naturally is corrupted. Seems that non-English letter became 2 bytes instead of one. I suspect it has something to do with the encoding.</p>
  <p>How I could possibly correct this so the file is recorded correctly?</p>