Variable-length binary string type in PostgreSQL
Questions tagged [bytea]
189 questions
3
votes
1 answer
How to store byte from Java into a bytea in PostgreSQL?
I am getting a problem when I try to insert a variable of type "byte" in Java into a variable of type "bytea" in PostgreSQL.
This is my table in postgresql:
CREATE TABLE mesa (
id_mesa serial PRIMARY KEY,
tag …

Renato Pereira
- 834
- 2
- 9
- 22
3
votes
2 answers
Retrieving file from bytea in PostgreSQL using java
Hi I'm using the below code to retrieve the file from the postgresql bytea using java,
but inside the file I'm getting numbers like 314530413142313141
File file = new File("c:/test.doc");
FileOutputStream fos = new…

Sathish
- 4,403
- 7
- 31
- 53
2
votes
1 answer
How do I store and fetch bytea data through hasura?
I've got a blob of audio data confirmed to play in the browser but fails to play after storing, retrieving, and conversion of the same data. I've tried a few methods without success, each time returning the error:
Uncaught (in promise) DOMException:…

Kyle Truong
- 2,545
- 8
- 34
- 50
2
votes
0 answers
Bytea parameter in a prisma raw query
I am using Typescript + Prisma + Postgres and I am running into problems with passing bytea/Buffer parameters to raw queries.
Let's say I have a following DB schema
model Item {
id BigInt @id @default(autoincrement()) @db.BigInt
hash …

radoh
- 4,554
- 5
- 30
- 45
2
votes
1 answer
Which is the best datatype to store UUIDs in PostgreSQL?
I am trying to store UUIDs in a posts table (posts - social media like it doesn't matter), and I would like to know which is the correct way to store UUIDs in PostgreSQL. I have tried to convert them into bytes and store them into binary(16)…

Monsta
- 25
- 3
2
votes
1 answer
Does Postgres store bytea data as hex on the server?
To work with bytea values in PostgreSQL, I usually am serializing to and deserializing from hex. This seems to be the preferred way. However, what is actually stored on the PostgreSQL server? Is it hex, or the unhexed binary? The reason I care is…

CJ Cobb
- 105
- 5
2
votes
1 answer
How to convert Postgres bytea to base64 string
I have a base64 image that I am trying to save in a Postgres database (using Hasura). The field is of type bytea I am not sure how to save this data to the field.
I tried passing data:image/png;base64,sisodjodo... to the field, and it saves it like…

Get Off My Lawn
- 34,175
- 38
- 176
- 338
2
votes
1 answer
how to convert byte array to base64 encoded format?
I have a page to download a file from the Postgres database. Now I can hit the following URL to view the file content present in the database(stored as bytes)-HTTP://sandbox4.wootz.io:8080/api/blob/1/UploadFile/hope%20real.txt
Since the data is…

Vignesh Swaminathan
- 319
- 1
- 9
- 24
2
votes
1 answer
Can not set [B field fr.mypackage.MyClass.data to java.lang.String
I am struggling with this problem :
org.hibernate.PropertyAccessException: could not set a field value by
reflection setter of fr.mypackage.MyClass.data
Caused by: java.lang.IllegalArgumentException: Can not set [B field
fr.mypackage.MyClass.data…

CommonPeople
- 700
- 1
- 6
- 16
2
votes
1 answer
lo_create(0) how to use with insert query
insert into hospital_image
select 'HospitalImage',
lo_from_bytea(1,decode('/9j/4AAQSkZJRgABAQEA3ADcAAD','base64')),
'jpg',
'123'
where not exists (select null from pg_largeObject where loid=1);
CREATE TABLE hospital_image (…

Ravi
- 159
- 3
- 17
2
votes
0 answers
How to stream a file (bytea) from Postgresql using Node and Angular?
I have an app with Angular 4 frontend and Node (express) backend. I have files (.doc, .pdf etc.) stored in postgresql as bytea type columns.
I would like to provide the user with a download link in the front end without storing the file temporarily…

San
- 3,933
- 7
- 34
- 43
2
votes
3 answers
proper hibernate mapping for @lob in Hibernate pojo. we are using hibernate mapping. can you please tell me equivalent for @lob annotation
We are using hibernate mapping. In hibernate configuration file we have given type="blob" and pojo class getBlob and setBlob methods we have. Apart from this we need to have @lob right. what is equivalent for lob in hibernate…

Ravi
- 159
- 3
- 17
2
votes
1 answer
phoenix elixir binary data image
Im using the phoenix framework to create a webpage and created an upload form to give the user the possiblity to upload a profil picture.
def update(conn, %{"id" => id, "user" => %{"photo" => file}}) do
if(File.exists?(file.path)) do
…

murphy1312
- 553
- 9
- 18
2
votes
1 answer
How do I represent postgres `bytea` type in slick 2.0.1?
In slick's documentation it's said that java.sql.Blob is one of types supported out of the box and I'm attempting to use it to represent bytea column. But the following code gives me an error:
import scala.slick.driver.PostgresDriver.simple._
import…

src091
- 2,807
- 7
- 44
- 74
2
votes
1 answer
Hibernate postgres bytea retrieval issue
I am using Hibernate 4.0 to store jpegs into postgres 9.1.4 (jdbc is postgresql-9.1-901.jdbc4.jar) bytea column(byte[] is the hibernate entity, without extra type def).
The hibernate storing process works fine because I can use Database tools to…

snlm95
- 75
- 2
- 8