title: Node.js: How to append files to a (archiverjs) zip from url
body: <p>I have an object containing an array of slides. Every slide <strong>can</strong> have a media parameter containing the url to an image or video file or the link to a youtube or vimeo video.</p>
  
  <p>My goal is to have the slides viewer zipped and inside the zip I also must have the image or video files taken from the urls.</p>
  
  <p>To create the zip I'm currently using <a href="https://github.com/archiverjs/node-archiver" rel="noreferrer">Archiver</a> and it works fine, but I don't know how to put the media files inside the zip (possibly) without writing them on the filesystem first. I think I have to use streams, since archiver.append() can take a stream as first parameter, but I don't know how to do that.</p>
  
  <p>I have implemented some code to understand if the url points to a file or not, writing the files' url inside an array (avoiding youtube or viemo urls).</p>
  
  <p>This is how the zip is created:</p>
  
  <pre><code>...
  var urls_array = ["http://url1/file1.jpg", "http://url2/file2.png"]; //the array of urls I take the media files from
  
  var zip = archiver('zip');
  zip.pipe(res);
  
  zip.directory(__dirname + '/../../zip/', 'slideshow');
  zip.append( new Buffer( file ), { name: 'slideshow/assets/slides.json' });
  zip.finalize();
  </code></pre>
  
  <p>I suppose I have to cycle the <code>url_array</code> and for each url perform a <code>http.get()</code> call, but I can't understand how to <code>.pipe()</code> the response inside the zip.</p>
  
  <p>Is there anyone who can help me?
  Don't hesitate to ask me more information :)</p>
  
  <p>Thank you in advance.</p>