Skip to content

Instantly share code, notes, and snippets.

View 11joselu's full-sized avatar
🎯
Focusing

Jose Cabrera 11joselu

🎯
Focusing
View GitHub Profile
@11joselu
11joselu / fileUtils.js
Last active March 7, 2018 17:39
Donwload File - Vue.js 2.x
export function getFile(response) {
var result = document.createElement('a');
var contentDisposition = response.headers.get('Content-Disposition') || '';
var filename = contentDisposition.split('filename=')[1];
filename = filename.replace(/"/g,"")
return response.blob()
.then(function(data) {
result.href = window.URL.createObjectURL(data);
result.target = '_self';