you need a column in a postgresql table with the type OID

create table files(
file_id serial primary key,
file oid not null
);

to insert file

INSERT INTO files(file) values(lo_import('/tmp/filename.ext');

to read the file

SELECT lo_export(file, '/tmp/filename.ext') WHERE file_id=2;

you can get the file in the /tmp/filename.ext.

store upload image postgresql