Search code examples
javascriptnode.jsjsonimageoctetstring

How shall I convert application/octet-stream into image to be displayed in base64 or any jpeg format?


I am trying to send a image from social media to trigger to web hook and thus to receive in my application. But here web hook is responding in a application/octet stream. But in order to display / read the image, I need it to be in base64 or any jpeg format. I tried multiple stuffs but still no success. Can anyone help me out in this ? response received is similar to this

�����JFIF�����������


""$$6*&&*6>424>LDDL_Z_||�


""$$6*&&*6>424>LDDL_Z_||������"����/���������������������������������P����
C �"�1I����Y�Y�Y�MS�B>�B�t%�x�1Dۻ83L�?R�sh���s���qlslU��fR�e �1��e�mh���
�10
�`�����10�����Pd%���,��%��0@�4���
��&��x��8����&5cF�7.����o��Ce!x�WN�cJ��l�:����N�Ϻ�ނ��H<�坦+Y�)=l��cY¦��������,mG �Z�I��`Lb`�d���&10�0���0����C����5��!��0@`���!��x�jX�#���H�e4��Q6a�A��q�/*�5P����j��̝4�B�+e�ˈt񊱽��Da���:�ˢ2�Md(�`�1=T�kye}�Z&��`L��Lbc��������10�b&10�����
PХd��w�`��4�h���!�Mh�j�eX�w�$�oY�͙-��RA��Ѣ��N�gG3I;�åX֍t��Ԕ�[������+�����r����@��:��oMʴ16�0��0���a���8�11��C��&1�b��1T0�� ��1;���S@��� 4�h��� �x�j�'C>��
$�  M���h�I5V�m/>k�TՖ%��9��)��D5�]Y���u,Ζ%�� ����;���R��c��0�����0�������0&�L�`���C���0I�]"]ʠ0@h��&�L�����������A�3U��FtG�tt��g�L���gX��%�r�s����`��e�*KS�����l��bV�e

Solution

  • Buffer.from(body).toString('base64');