Show image base64 on angularjs of any extension

Viewed 29

I allow user to save image as blob on the database, when I try to load the image that the user has save , I have a problem, In my html code i try to show the image like this:

<img [src]="'data:image/jpg;base64,'+mybase64variable" />

My problem is that the image is not always in exteion jpg so how can I know which extension I´m recieving and how can I split data:image/jpg from the other part.

My base 64 string looks like this:

"dataimage/jpegbase64/9j/4AAQSkZJRgABAQAAAQABAAD/2wB..

So I need to separete dataimage/jpegbase64 this part to know the extension of the image

1 Answers

My problem was that I was coding the base64 String with a method of a class(java.util.base64) and I was decoding with other method of other class, so when I was decoding it, I was returning a wrong base64 string.

Related