2
I am receiving a PDF file in the Answer of a POST request, and on the server side I have configured the file name and everything else. But now I’m visualizing it in the browser instead of downloading it and it no longer obeys the name placed on the server and is assigning another name, like this: "2050102b-7041-4cfa-9ebf-0c05af158005" and I’m not getting it to receive a specific name Besides the name being weird, the URL in the browser looks like this: "blob:http://localhost:8080/2050102b-7041-4cfa-9ebf-0c05af158005"
Server:
stream.on('finish', function() {
if (fs.existsSync('C:/Projetos/Relatorios/pdfs/Tabela.pdf')) {
let options = {
root: '../pdfs/',
dotfiles: 'deny'
};
let fileName = 'Tabela.pdf';
res.sendFile(fileName, options, function (err) {
if (err){
console.log(err)
}else{
console.log('Arquivo enviado!')
}
});
}
})
Client:
let link = document.createElement('a')
link.target = '_blank'
let url = window.URL.createObjectURL(blob);
link.href = url .split('/')[0] + '/' + url .split('/')[1].replace(/.*/, 'meuarquivo.pdf');
Server: Express 4.15.0
Client: Vuejs/Quasar-Framework