0

I uploaded the image in mySQL database as BLOB, and other attributes as text using a POST API. While executing a GET API. I am seeing the image as <Buffer 89 50 4e 47 0d 0a 1a 0a 00 00 00 0d 49 48 44 52 00 00 00 a2 00 00 00 94 08 06 00 00 00 10 d1 f2 ab 00 00 00 01 73 52 47 42 00 ae ce 1c e9 00 00 00 04 ... 11139 more bytes>

What is this format called? And how could I convert this back to image (as seen by user) in Angular14?

enter image description here

Tanish Gupta
  • 400
  • 2
  • 8
  • 20
  • in node.js - it's a [Buffer](https://nodejs.org/api/buffer.html) – Jaromanda X Sep 07 '22 at 06:00
  • How could I change that to a normal picture. – Tanish Gupta Sep 07 '22 at 06:02
  • Well, you've put binary data in your MySQL database, now you're getting binary data (a list of bytes) back. If you need to embed the binary data in a JSON response, you could encode it to a base64 `data://` URL; that could be directly used in ``.. – AKX Sep 07 '22 at 06:04
  • @AKX in mysql CLI I am seeing the image as `0x89504E470D0A1A0A0000000D49484452000000140000001408060000008D891D0D0000000467414D410000B18F0BFC6105000000097048597300000EC100000EC101B8916BED0000001874455874536F667477617265007061696E742.......` and in the POSTMAN I am seeing as binary data, whereas the datatype is longblob. How could I convert this to base64 – Tanish Gupta Sep 07 '22 at 06:28
  • 1
    In Node.js, `buffer.toString("base64")`. – AKX Sep 07 '22 at 06:29

0 Answers0