How to store files into the DB with PHP. (bytea ?)

From: " François Delpierre" <pgsql(at)pivert(dot)org>
To: pgsql-php(at)postgresql(dot)org
Subject: How to store files into the DB with PHP. (bytea ?)
Date: 2009-02-02 10:02:05
Message-ID: 200902021102.06157.pgsql@pivert.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-php

Hi,

I know this question came quite often, but I never found a clear answer in the
mailing list.

My problem :
- I need to store files (pdf, png, jpg) from a web page in PHP.
- I have a strong need of security and high availability. I must minimize the
risk of having these documents stolen if the web server is compromised.

My questions :
- Which datatype ? (once again, sorry.). (Text, bytea, lo) ?
- Most of samples redirect to lo (large objects), and PHP has a set of
dedicated functions for them. But in the documentation we can read :

All large objects are placed in a single system table called pg_largeobject.
PostgreSQL also supports a storage system called "TOAST" that automatically
stores values larger than a single database page into a secondary storage area
per table. This makes the large object facility partially obsolete.

Why obsolete ? Is it now because of TOAST that we can store up to 1GB into
bytea ? If bytea is the easiest solution, why do so many people redirect to LO
?
LO stores the datas within only one table, pg_largeobject, I really prefer to
store the big datas within my custom table stored on a dedicated tablespace.

Due to the high security level of my web application, all the datas must be
accessed through stored procedures. Does it change something to the choice ?

Where can I find samples of files stored through PHP & stored procedures ?

Regards,

--
François Delpierre

Responses

Browse pgsql-php by date

  From Date Subject
Next Message tv 2009-02-02 11:55:04 Re: How to store files into the DB with PHP. (bytea ?)
Previous Message Chris 2009-01-26 23:04:07 Re: Persistent connections