AngularFileDownloader is a simple, easy-to-use library for downloading files through REST, allowing altering the request.
- You using $http interceptors with authorization logic
- You need to provide custom headers
Angular ~1.5.*
- Include
angular-file-downloader.js
in your index.html - Include
fileDownloader
service in your app configuration
angular
.module('yourApp', [
...
'angularFileDownloader',
...
]);
- You can use provided Angular component
downloadLink
, example usage:
...
<download-link href='AAA' headers='{"xxx":"yyy"}' mime='application/pdf'>
<button>Download</button>
</download-link>
...
Please note that headers expects to receive JSON.parse style string
-
You can use
fileDownloader.downloadFile(url, mime, additionalHeaders)
functionparameters:
url
- file url to download frommime
- content mime type should be set, defaulttext/plain
will be used if not setadditionalHeaders
- headers object that should be added
- bower
bower install angular-file-downloader --save