Home > Back-end >  Issue storing images in Postges database - permission denied
Issue storing images in Postges database - permission denied

Time:09-10

I have a small database in which I want to store images in a separate table. I have been reading different methods and believe due to the small size of the DB there is no issue in physically storing the image within the DB.

I have been reading and trying to get the sql code correct in order to upload one image into a new table. However I am running into "SQL Error [42501]: ERROR: could not open file.... for reading: Permission denied".

I have tried to change permission access by clicking Command I on the folder and at the bottom adding "postgres" with "Read & Write" privileges. I closed DBeaver and still not luck.

Is my approach and sql code correct for uploading and image? How do I get around permissions?


create table category  (
"id_category" SERIAL,
"category_name" TEXT,
"category_image" bytea,
constraint id_cat_pkey primary key ("id_category"))without oids;

insert into category (category_name,category_image) values('MANGO', pg_read_binary_file('tmp/IMG_2405.jpeg')::bytea)

CodePudding user response:

I was able to upload the image to postgres. I had to move the picture to a folder with in the same directory as postgres. I am still working how to give permission to folders outside of postgres.

  • Related