I have been trying to display and download a binary (octet-stream) file that i got from an API's response.
I tried converting the file to base64 and displaying it in href and in an iframe, and showing the file directly with its MINE TYPE (Application/pdf) and default type (Application/octet-stream) but none of the above worked.
data: "PDF-1.7
%����
301 0 obj
<</Linearized 1/L 366634/O 303/E 356306/N 1/T 366300/H [ 900 415]>>
endobj
462 0 obj
<</DecodeParms<</Columns 5/Predictor
12>>/Filter/FlateDecode/ID[<C63CE28E0F04F6408738C45693E2B214>
<EE45F3FA04D9F349A93DBCE0FF820FE0>]/Index[301 176]/Info 300 0 R/Length
339/Prev 366301/Root 302 0 R/Size 477/Type/XRef/W[1 3 1]>>stream
hެ��/DA������-�V�,�(44J�F����F$�V!*�(6!����D)�/
����uZ�h�[8'���
䗓;g�ޙ�bL�Xc�>����ͫS�d^Új[uO�q�ur�֏ʊx�m���f^x-n��ln�R$.��
������=��?c�9��P㮈
�(�S��q��)�`��&y�ρK�a�֎�O�;�� �r��KH.....
content-length: "366634"
content-type: "application/octet-stream"
When i try to show the file in window with innerHTML i get "Error loading pdf document" and the same goes for image files.
Is there a way to either properly convert the file to base64 and display/download it (I've done that before but the API response was a base64 file) or just display the file in octet-stream as it is.