title: Download file from API using javascript
body: <p>I need to force download of file using JavaScript. I am using Angular and restangular to communicate with API. I am now working on file download action from API... API returns me raw bytes of that file and these headers:</p>
  
  <pre><code>Content-Disposition:attachment; filename="thefile"
  Content-Length:2753
  </code></pre>
  
  <p>So I have raw bytes, but I do not know how to handle it to download this file to client...Can you provide me some solution of this issue? How can I handle returns response from server to open in client browser Save As dialog?</p>
  
  <p>EDITED:
  Server does not send me content-type of the file...Also in call's headers need to be auth token so I cannot use direct open window with url..
  Code is:</p>
  
  <pre><code>vm.downloadFile = function(fileId){
   var action = baseHelpers.one('files/' + fileId + '/content').get();
   action.then(function(result){});
  }
  </code></pre>