How can I insert attachments to JSONB using PostgreSQL ?
Is any special key, like "_attachments:{}" ? Where Can I find in manual, about inserting files, binary data, attachments ?
How can I insert attachments to JSONB using PostgreSQL ?
Is any special key, like "_attachments:{}" ? Where Can I find in manual, about inserting files, binary data, attachments ?
This really has nothing to do with PostgreSQL its self, it's down to the JSON object-serialization format, rather than PostgreSQL's implementation of it.
JSON is a text-based serialization, so you cannot embed binary data in it directly.
You must encode it to a form that's valid encoded text with no null bytes, etc.
Typically you do this by encoding it as base64 or base85.
In PostgreSQL you'll want to use encode(some_bytea, 'base64')
and the corresponding decode
call. PostgreSQL doesn't have built-in base85 support.
See: