1

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
V K
  • 87
  • 4
  • 13
  • You can follow this [link](https://stackoverflow.com/questions/1095102/how-do-i-load-binary-image-data-using-javascript-and-xmlhttprequest) to the similar question – TND Feb 12 '20 at 10:55
  • @V-k did you find the solution to this?. i have a simillar problem. https://stackoverflow.com/questions/69456386/invalid-character-when-displaying-image-in-base64-string-from-express-server-to – Edijae Crusar Oct 05 '21 at 21:16

1 Answers1

2
Buffer.from(body).toString('base64');
dfritsi
  • 1,224
  • 3
  • 14
  • 24
  • Hi, I tried this I am getting this 414 Request-URI Too Large when I am trying to load the blurred icon – V K Feb 12 '20 at 10:57
  • But does the octet stream get serialized into base64 correctly? So does my code give you the correct result? When does to 414 error occur? After you deserialized the stream into base64 or while you are trying to execute the above code? I suspect the 414 error is coming from the server. You can configure various servers in different ways to enable a larger buffer. How does your complete application look like? What server are you using, etc.? By the way your question is not very descriptive. I only figured out you are talking about nodejs from the tags. – dfritsi Feb 12 '20 at 11:13
  • I have to send image from any social media suppose its WhatsApp, those request will be sent to some web hook which is configured with my local ip. then when I need to receive it in my web application so that I can respond to sent message. there the image sent is coming in application/octet stream so its not getting possible to read it in web application. – V K Feb 12 '20 at 12:11
  • So: 1.) You want to get an image from example from WhatsApp. 2.) You then want to send this image to a webserver. 3.) ??? I don't get this part: "hen when I need to receive it in my web application so that I can respond to sent message". Can you please also describe what framework / programming language you are using in each step? E.g.: I am downloading the image from WhatsApp using jQuery in JavaScript, then I'm sending it to a webserver using jQuery again. The webserver is written in Java using Spring MVC. This is just an example. You need to fill in the blanks so I can help you. – dfritsi Feb 12 '20 at 13:34
  • Also you need to tell us which step is failing. I'm also not sure what's the problem with processing the image. An image is usually in a binary format. Why do you need it in BASE 64? Do you need to store it in a db? – dfritsi Feb 12 '20 at 13:34
  • @dfritsi this dint work. see my question here https://stackoverflow.com/questions/69456386/invalid-character-when-displaying-image-in-base64-string-from-express-server-to – Edijae Crusar Oct 05 '21 at 21:15