B
B
beduin012016-05-21 19:29:36
PostgreSQL
beduin01, 2016-05-21 19:29:36

How to insert a binary blob in PostgreSQL?

I write like this:

UPDATE "REQUESTS" SET shape= pg_read_file('123.jpg')::bytea WHERE request_id>0;

An error is thrown:
ERROR: invalid byte sequence for encoding "UTF8": 0xff

How to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Melkij, 2016-05-21
@beduin01

www.postgresql.org/docs/9.5/static/functions-admin.html
In short, why are you trying to read the binary with a text function, and do not take the regular pg_read_binary_file, which just reads bytea.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question