0

I'm doing a project with Angular 8 where I need to get an image with binary format. After my request I get a lot of data with this profil:

�PNG


IHDR�P�� -sBIT|d�tEXtSoftwaregnome-screenshot��> IDATx�

(a lot more data) I want to display the image but I can't, I tried to use btoa() but the fonction return nothing, impossible to even do the log.

At the end after trying many things I have this

        let test = encodeURIComponent(result.response);
        console.log(test);
        let img = "data:image/png;base64," + btoa(test);
        vm.billData.image = img;

The image isn't showing anyway. Can someone help me ?

4
  • 1
    In my previous project, I had the same problem showing a pdf file which I get from server in the binary format you showed. It worked after sending "responseType:'blob'" in request params Commented Feb 22, 2020 at 13:34
  • you're a monster thanks a lot ! Commented Feb 22, 2020 at 13:39
  • @PrakashReddyPotlapadu write it has answer, so others can benefit from this. Commented Feb 22, 2020 at 14:46
  • @SatishPai Sure will do Commented Feb 22, 2020 at 14:56

1 Answer 1

2

I faced the same challenge in my previous project. I had to show a PDF file which i receive from server in the binary format. It worked After sending responseType:'blob' in request params

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.