this is my first stack post, sorry if it's a little blurry :/
So basically I have a Angular project with firestore behind. I got a cloud function which generates an .xlsx file and upload it to my fireStorage.
const path = 'hellothere/excels';
return workBook.xlsx.writeFile(`/tmp/myExcel.xlsx`).then(() => {
return storageFb.upload( `/tmp/myexcel.xlsx`,{
destination: path '/myExcel.xlsx',
}
)
}).then(() => path);
Where StorageFb is the bucket of my storage.
Actuelly it's working, it uploads my .xlsx file under /hellothere/excels/ with the name myExcel.xlsx. But when I download it (by the admin panel or my angular client), it is fully named hellothere_excels_myExcel.xlsx.
Here is my client code:
this.fireStorage.ref('hellothere/excels/myExcel.xlsx').getDownloadURL().subscribe((url) => {
window.open(url, '_blank');
});
return Promise.resolve();
Simply. I know the code is messy but i'm testing all solution I can find so i'll clean it up afterall
So I'm kinda stuck since I dunno why those file won't download with just the 'myExcel' name. If anyone have a clue you'll save my week ahah ! Thanks !
CodePudding user response:
You need to set the content disposition to define the filename. Try that
const path = 'hellothere/excels';
return workBook.xlsx.writeFile(`/tmp/myExcel.xlsx`).then(() => {
return storageFb.upload( `/tmp/myexcel.xlsx`,{
destination: path '/myExcel.xlsx',
contentDisposition: 'filename=myExcel.xlsx'
}
)
}).then(() => path);
