title: Download multiple files using JavaScript
body: <p>I'm very new to this so am learning by trial and error.</p>
  
  <p>I have a javascript which so far is authorising access to a users Google Drive. It creates an array of some files it finds and I can access the meta data to get the DownloadURL of each file.</p>
  
  <pre><code>function downloadFile() {
              gapi.client.load('drive', 'v2', makeRequest);
          }
  
  
          function makeRequest() {
              var request = gapi.client.request({
                      'path': '/drive/v2/files',
                      'method': 'GET',
                      'params': {'q': 'title contains "This"'} // retrieve all files with a filename that begins with the word "This"
                  });
  
              request.execute(function(resp) {
  
                  for (i = 0; i &lt; resp.items.length; i++) {
                      var dlUrl = resp.items[i].downloadUrl; //this is the url extracted from the request
                      var finalDlUrl = dlUrl.split("&amp;gd=true");//the url needs to be trimmed so the last 8 characters are ignored in order to work
                     window.location.assign(finalDlUrl);
  
  
                  }
              });
  </code></pre>
  
  <p>How do I get the script to loop through each of the file array elements and download each one. I know to use a 'for loop' but what is the actual way of triggering the file downloads so they appear in my browser downloads folder.</p>
  
  <p>also, and it may be related, what is the syntax to include the alt=media parameter in a http request when using <code>gapi.client.request({/* etc */})</code></p>