While working on my angular app, I encountered a situation where I needed to download user details uploaded as a Word document to my local machine using the angular app. Successfully, I was able to upload and save this data to my database, getting its byte[] data on the client side.
To perform the save action on the client's machine within my angular app, I utilized npm i file-saver. However, an error started appearing in the console whenever I tried to execute the saving process.
https://i.sstatic.net/j5nTJ.png
The console output of my result after making a GET call to the API looked something like this:
https://i.sstatic.net/u4jIS.png
I attempted to use result.blob without success. Does anyone have any ideas?
In search of a solution, I came across mentions that this functionality has been removed from the current version of Chrome. How can I work around this issue?
UPDATE
Two changes were made:
Firstly, I modified my TypeScript code as follows:
this.dataservice.getResume(method, id).subscribe(blob => {
const file = new Blob([blob], { type: 'application/pdf' });
saveAs(file, name+'_resume.pdf');
Now, the file downloads as a .pdf. However, upon trying to open the file, I encountered a "failed to load" error :/
Referencing my request header, it appears as follows:
let headers = new HttpHeaders()
.set('Authorization', 'Bearer ' +
this.securityService
.securityObject.bearerToken);
return this.http.get(environment.baseApiUrl + methodName + id, { headers: headers , observe: 'response', responseType: 'blob' });