Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- downloadFile(fileId) {
- axios({
- url: 'http://localhost:8081/download?fileId=' + fileId,
- method: 'GET',
- responseType: 'blob',
- headers: {
- Authorization: 'Basic ' + localStorage.getItem('user')
- }}).then((response) => {
- const url = window.URL.createObjectURL(new Blob([response.data]));
- const link = document.createElement('a');
- link.href = url;
- link.setAttribute('download', 'file.pdf'); //or any other extension
- document.body.appendChild(link);
- link.click();
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement