title: Not able to download multiple files from S3 pre-signed urls using JS
body: <p>Before I start with the question, I have gone through multiple stackoverflow answers around similar sort of questions (including those which have been asked and not answered till now). I have also gone through one of the medium articles. So, I have done a fair bit of research.</p>
  <p>I have been trying to download multiple files using presigned urls. The code below was working few days back (this might sound familiar ;)) but currently, I am just able to download one file that too the download is random. Sometimes the first file is downloaded and sometimes the last. Code is provided below:</p>
  <pre><code>downloadItem() {
    let urls = [];
    for(let item of this.selectedRowsData) {
      //calling the service to fetch the presigned url
      this.dataService.getPresignedToDownloadAll(
        item.value,
        item.id).subscribe((res) =&gt; {
          urls.push(res);
          this.download(urls);
          /**if(urls.length === selectedRowData.length) {
             this.download(urls);
          }**/ //have tried this code too where I just invoke download only once when I have all the presigned urls
      });
   }
  }
  download(urls: any) {
    var self = this;
    var url = urls.pop();
    setTimeout(function(){
      self.snackBarService.loadComponent({
        isSuccess: true,
        message: MESSAGES.downloadInProgress,
      });
    var a = document.createElement('a');
    a.setAttribute('href', url);
    document.body.appendChild(a);
    a.setAttribute('download', '');
    a.setAttribute('target', '_self');
    a.click();
    // a.remove();
    }, 1000)
  }
  </code></pre>
  <p>Any help is much appreciated.</p>