I'm using Angular and TypeScript to send some files to the user using googleapis storage service. Whenever I send a geojson file to download, instead of downloading it to the computer, it just opens the file in a new tab without downloading it. I'm creating the file in the backend server, saving it to the google service, and then sending the download url to the user. When I use this function to download KML files, it downloads just fine, but when I try to download geojson it just opens it as plain text in a new tab. How can I make it download as a normal file?
const download_url = res.download_url;
saveAs(download_url, 'sample2.kml');
Use this function:
downloadFile(data: Response) {
const blob = new Blob([data], { type: 'text/csv' });
const url = window.URL.createObjectURL(blob);
window.open(url);
}