I have binary data that I want to show as a preview in my modal
The binary data is as seen in the below image in Response:-
The same data is seen in preview:-
If I hardcode the preview value in code then it works. But if I take the response from API then it doesn't work.
How to get the preview as seen in the preview image without hardcode ?
This works:
clickedFile.image = "/9j/4AAQSkZJRgABAQEASABIAAD/4QHDRXhpZ.."
var myBase64 = "data:"+file.fileType+";base64,"+clickedFile.image+"";
var img = new Image();
img.src = myBase64;
But this doesn't works:
clickedFile.image = api.response;
var myBase64 = "data:"+file.fileType+";base64,"+clickedFile.image+"";
var img = new Image();
img.src = myBase64;
So how to convert binary response api.response
to its preview value "/9j/4AAQSkZJRgABAQEASABIAAD/4QHDRXhpZ.."
?
UPDATE:
Using REST Client, I can see the following dialogue: CANNOT PREVIEW IMAGE