3

I have a table to store file information in postgresql.

select id,filestream,name from Table_file_info

enter image description here

Here filestream is bytea datatype. How to get bytea data into actual text (content of my file) in postgresql.

I tried with below query:

select encode(filestream, 'escape')::text as name from Table_file_info

but i am getting as below

ICAgICAgICAgc2FkZnNhZGZhZCBzZGRkZGRkZGRkIFRlc3R0dA==

actual content of my file is: sadfsadfad sddddddddd Testtt enter image description here

Jagadeesh
  • 1,630
  • 8
  • 24
  • 35

1 Answers1

2

It looks like base64. Meaning your file was first converted to base64, then converted to bytea (which is kind of pointless since base64 is already text)

select encode(decode(encode(filestream,'escape'),'base64'),'escape') from Table_file_info;
jjanes
  • 37,812
  • 5
  • 27
  • 34