Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function(data, status, headers) {
- var fileType = headers('Content-Type');
- var disposition = headers('Content-Disposition');
- var fileName = '';
- if (disposition) {
- var match = disposition.match(/.*filename=\"?([^;\"]+)\"?.*/);
- if (match[1])
- fileName = match[1];
- }
- fileName = fileName.replace(/[<>:"\/\\|?*]+/g, '_');
- var blob = new Blob([data], { type: fileType });
- var objectUrl = window.URL || window.webkitURL;
- var link = angular.element('<a/>');
- link.css({ display: 'none' });
- link.attr({
- href: objectUrl.createObjectURL(blob),
- target: '_blank',
- download: fileName
- })
- link[0].click();
- // clean up
- link.remove();
- objectUrl.revokeObjectURL(blob);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement