Skip to content
Advertisement

How to dowload a file (blob) which is Int8Array in Angular

I am trying to download a file in Angular. The file is saved in db as varbinary. Java REST service fetched it as byte[]. I am having it as Int8Array in Angular. However when I download it I beleive it is base64 encoded

JavaScript

This is how it is in MSSQL: 0x323032312D30392D323720303 ... And this is how it is when I download this xlsx and open it: MjAyMS0wOS0yNyAwNzozMDsxMi4wODI7bT

I beleive it is base64 encoded somewhere in that path from sql to browser…I saved it in a SQL like this 'CAST('this is my xslx' AS VARBINARY (MAX)) so I know it should be this text.

Advertisement

Answer

The solution was to change a type in Angular from Int8Array to string and then I could use atob() method to decode from base64. I just don’t know why is it in base64. Could it be because I use Spring Boot ResponseEntity …

JavaScript
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement