I do not understand why I can not see the image that I have inserted in my heroku postgresql and why the images are full of \ characters when I load them from the website itself.
This is the update statement that works fine in the localhost and shows the images correctly:
UPDATE blog SET IMAGE= '89504e40_I_DELETED_THE PART_IN_BETWEEN_TO MAKE_IT _SHORTER_90b21a0508bee0e2cde637fd31c249274ecce90000000049454e44ae426082', IMAGE_CONTENT_TYPE='image/png' where id>0;
When I get in the heroku database with PGAdmin4 I see it like [binary data] and it is not shown in the web, BUT when I download a CSV from the database the images are there.
AND when I enter in the website and change an image, it goes into the database without problem as [binary data], downloads on the CSV BUT with a difference: it is full of \ and the characters
8,"2018-06-08 08:08:00","Blog Title 8 COMMUNITY_ID 5","\377\330\377\340\000\020JFIF\000\001\001\000\000\001\000\001\000\000\377\333\000\204\000\011\006\007\010\007\006\011\010\007\010\012\012\011\013\015\026\017\015\014\014\015\033\024\025\020\026 \035"""" \035\037\_DELETE_THE_MIDDLE_40?\377\331","image/jpeg","5"
This is regular image that shows no \ in the data:
8,"2018-06-08 08:08:00","Blog Title 8 COMMUNITY_ID 5","89504e470d0a1a0a0000000d4948c249274ecce90000000049454e44ae426082","image/png","5"
What is heroku postgresql changing here? Are they using a different format? What can I change in my update statement to make it work directly?
Thanks for you help!
I think you should DECODE it like this:
UPDATE blog SET IMAGE= decode('89504e470d0a1a0a0000000d4948445200000103000000c208030000007acc575c00000003504c5445000000a77a3dda0000004849444154789cedc13101000000c2a0f54f6d0c1fa000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000080b701c508000164aa1fd00000000049454e44ae426082', 'hex'), IMAGE_CONTENT_TYPE='image/png' where id>0;
See this answer Transition H2 data to PostgreSQL