I'm new in angular and I need to know how to save file from my API on a user computer. In my API, I have DownloadController with downloadChapter method on /download/chapter/{id}. When I call this method from Chrome, my computer just start downloading the chapter file - and it's ok. When I call this method form my DownloadService in angular I get the error in console: ERROR OK.
My download chapter method:
downloadChapter(id: number): Observable<Blob> {
return this.http
.get<Blob>(`${this.basicPath}/chapter/${id}`)
.pipe(
tap((res) => {
console.log(`response: ${res}`);
},
(e) => {
console.log(`error: ${e} - ???`);
}, () => {
console.log('win!');
}),
);
}
In API response:
200 OK OK,URL [file:/Users/lukasz/Workspace/Inz/api/booky/uploads/1/6:Solaris%20-%20Maly%20Apokryf.mp3],[Content-Disposition:"attachment;filename=6:Solaris%20-%20Maly%20Apokryf.mp3", Content-Type:"audio/mpeg", Content-Length:"97857000"]
How to fix it? I want to just save the file on a user computer.
https://github.com/eligrey/FileSaver.js