Received: from localhost (unknown [200.46.204.183]) by mail.postgresql.org (Postfix) with ESMTP id 2CD996326E1 for ; Mon, 2 Feb 2009 06:24:21 -0400 (AST) Received: from mail.postgresql.org ([200.46.204.86]) by localhost (mx1.hub.org [200.46.204.183]) (amavisd-maia, port 10024) with ESMTP id 42180-09 for ; Mon, 2 Feb 2009 06:24:17 -0400 (AST) X-Greylist: delayed 00:22:06.798422 by SQLgrey-1.7.6 Received: from mirapoint7.brutele.be (mirapoint7.brutele.be [212.68.199.151]) by mail.postgresql.org (Postfix) with ESMTP id 8E6FF63246E for ; Mon, 2 Feb 2009 06:24:17 -0400 (AST) Received: from abraham.pivert.org (user-85-201-95-140.static.tvcablenet.be [85.201.95.140] (may be forged)) by mirapoint7.brutele.be (MOS 3.10.3-GA) with ESMTP id KII80126; Mon, 2 Feb 2009 11:02:03 +0100 (CET) Received: from localhost (localhost [127.0.0.1]) by abraham.pivert.org (Postfix) with ESMTP id F02B01DD3C for ; Mon, 2 Feb 2009 11:02:00 +0100 (CET) X-Virus-Scanned: amavisd-new at appart.pivert.org Received: from abraham.pivert.org ([127.0.0.1]) by localhost (mail.pivert.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A-OX3rsVeOJP for ; Mon, 2 Feb 2009 11:02:00 +0100 (CET) Received: from bart.localnet (unknown [192.168.232.34]) by abraham.pivert.org (Postfix) with ESMTP id 6DB001DC3C for ; Mon, 2 Feb 2009 11:02:00 +0100 (CET) From: "=?utf-8?q?Fran=C3=A7ois?= Delpierre" To: pgsql-php@postgresql.org Subject: How to store files into the DB with PHP. (bytea ?) Date: Mon, 2 Feb 2009 11:02:05 +0100 User-Agent: KMail/1.11.0 (Linux/2.6.27-11-generic; KDE/4.2.0; i686; ; ) MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline Message-Id: <200902021102.06157.pgsql@pivert.org> X-Junkmail-Status: score=10/50, host=mirapoint7.brutele.be X-Junkmail-SD-Raw: score=unknown, refid=str=0001.0A0B0208.4986C49F.0330,ss=1,fgs=0, ip=85.201.95.140, so=2008-09-22 23:22:13, dmn=5.7.1/2008-09-02, mode=single engine X-Junkmail-IWF: false X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=0 tagged_above=0 required=5 tests=none X-Spam-Level: X-Archive-Number: 200902/1 X-Sequence-Number: 3977 Hi, I know this question came quite often, but I never found a clear answer in = the=20 mailing list. My problem :=20 =2D I need to store files (pdf, png, jpg) from a web page in PHP. =2D I have a strong need of security and high availability. I must minimize= the=20 risk of having these documents stolen if the web server is compromised. My questions : =2D Which datatype ? (once again, sorry.). (Text, bytea, lo) ? =2D Most of samples redirect to lo (large objects), and PHP has a set of=20 dedicated functions for them. But in the documentation we can read : All large objects are placed in a single system table called pg_largeobject= =2E=20 PostgreSQL also supports a storage system called "TOAST" that automatically= =20 stores values larger than a single database page into a secondary storage a= rea=20 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= =20 bytea ? If bytea is the easiest solution, why do so many people redirect to= LO=20 ? LO stores the datas within only one table, pg_largeobject, I really prefer = to=20 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= =20 accessed through stored procedures. Does it change something to the choice ? Where can I find samples of files stored through PHP & stored procedures ? Regards, =2D-=20 =46ran=C3=A7ois Delpierre