I've currently got a program that works in downloading a singular file from backend, constructing it into a blob and converting it to an excel. As seen below.
let filename = 'download' + this.EXCEL_EXTEN
await this.apiService.getDownload(info).then((response: any) => {
let download = new Blob([response.data]), {type: 'application/vnd.ms-excel' })
window['saveAs'](download, filename)
}) .catch((error) => {
console.log(error)
}
However, my requirements have changed. Instead, I'm being sent back 1 to many excel documents within a .zip folder and I'm not sure how I'm meant to construct the data properly. I've attempted to alter the type to be .zip, which does successfully download a zip, but the folder contains no data.
Did you correctly alter the MIME type to be a zip? Does the backend return a valid ZIP file? Here's an example implementation using FileSaver:
this.http.get('/api/download-zip', { responseType: 'arraybuffer' })
.subscribe((data: ArrayBuffer) => {
// Create blob of type zip
const blob = new Blob([data], { type: 'application/zip' });
// Use file-saver to prompt user to save file
FileSaver.saveAs(blob, 'my-excels.zip');
);