title: Download S3 file from pre-signed URL without popup blocker
body: <p>I have a Meteor application where I'm downloading files from S3 using pre-signed URLs (need to be generated with an API call).</p>
  
  <p>I was having an issue with popup blockers preventing a new tab from opening with the url generated by the AWS-SDK so I changed my code to the following:</p>
  
  <pre><code>downloadDocument(document, event) {
      // open tab immediately to prevent popup blocker
      const myNewTab = window.open();
  
      // call method to generate url
      Meteor.call('Events.Methods.Document.Download', { key: document.key, eventId: event._id }, (error, res) =&gt; {
        if (error) { ... } // removed handle error code
  
        // if url generated, set tab location to url
        if (res) myNewTab.location.href = res;
  
        // auto close the tab after 1 second
        myNewTab.setTimeout(() =&gt; { myNewTab.close(); }, 1000);
      });
  }
  </code></pre>
  
  <p>This code is working for the most part but it doesn't feel very clean. Also if the API call ever takes more than 1 second (slow internet) then the tab will close before the download begins</p>
  
  <p>How can I change this so that I can wait for the download to happen, before closing the tab? Or a similar solution that would result in me ensuring the downloads always go through without popup blockers being an issue?</p>
  
  <p>Thanks</p>