title: Download zip with axios and unzip with adm-zip in memory (electron app)
body: <p>I need to download a file with <code>axios</code> and unzip it in memory in an electron app.</p>
  <p>I read in some SO threads (<a href="https://stackoverflow.com/questions/10359485/how-to-download-and-unzip-a-zip-file-in-memory-in-nodejs">e.g.</a>), that <code>adm-zip</code> supports byte buffer constructor, but I can not see this in the docs. When I extract the content, it behaves like the array is empty, but it is not. It just does create a file and does not throw any errors I do not want to use <code>request</code>, as the api is marked deprecated. My code is this:</p>
  <pre><code>const axios = require(&quot;axios&quot;);
  const AdmZip = require('adm-zip');
     
  const url = &quot;http://update-service.test.w3champions.com/api/maps&quot;;
  const body = await axios.get(url, {
      responseType: 'arraybuffer'
  });
  const data = body.data;
  const zip = new AdmZip(data);
  zip.extractAllTo(to, true);
  </code></pre>
  <p>I feel super stupid, because I had it one time working and then changed something and now I do not seem to find the error again :/ I sadly did not commit the working state...</p>
  <p>edit:
  So, we figured it out: Electron does some weird stuff that returns an Array Buffer instead of a Buffer, that adm-zip would need. As I am lazy added the package <code>arraybuffer-to-buffer</code> and now the code works:</p>
  <pre><code>const arrayBufferToBuffer = window.require('arraybuffer-to-buffer');
  const url = `${this.updateUrl}api/${fileName}?ptr=${this.isTest}`;
  const body = await axios.get(url, {
      responseType: 'arraybuffer'
  });
  
  const buffer = arrayBufferToBuffer(body.data);
  const zip = new AdmZip(buffer);
  zip.extractAllTo(to, true);
  </code></pre>