I have base64 data of a file coming from API to react and need to read and download this file in it's actual form
PDF , doc , ..
or link the download action to a button
Asked
Active
Viewed 1,440 times
0

Amr Mansour
- 1
- 3
-
This is probable duplicate https://stackoverflow.com/questions/50694881/how-to-download-file-in-react-js – Vinicius Katata Apr 18 '21 at 17:10
-
not duplicated .. he has a url but in my case only binary data of the file – Amr Mansour Apr 18 '21 at 17:14
-
By binary you mean base64? – Vinicius Katata Apr 18 '21 at 17:20
-
yes and i want to return it to it's actual form //Note: the extension of the file can be pdf || xls || .docx ... – Amr Mansour Apr 18 '21 at 17:24
1 Answers
0
Try this:
<a download="filename.png" href="data:image/png;base64,foo...">Download</a>

Vinicius Katata
- 932
- 3
- 7
-
didn't work ,, just downloaded unknown file {the binary file itself} i want to get it back as pdf or whatever it's actual form was – Amr Mansour Apr 18 '21 at 17:38