pg.ddx.io  pgsql-php@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Stephen van Egmond <svanegmond@bang.dhs.org>
To: chriswood@wvda.com
Cc: pgsql-php@postgresql.org
Subject: Re: Question re large objects
Date: Tue, 28 Nov 2000 13:29:23 -0500
Message-ID: <20001128132923.B30495@bang.dhs.org> (raw)
In-Reply-To: <3A23B26E.9056.2942B3@localhost>
References: <3A23B26E.9056.2942B3@localhost>

chriswood@wvda.com (chriswood@wvda.com) wrote:
> I've considered the alternatives (store files in a directory or in the 
> db), and I think storing the image files in the database is the way to 
> go. Unless anybody can think of why I should just upload the files 
> to a directory on the server instead of storing them as BLOBs.

Because you will lose the images when you do a restore from backup.
And you will have to restore from backup eventually, count on it.

On the other hand, if your service will ever grow to more than one
computer doing HTTP service (i.e. load balancing), you will have to
have the items in the database or resort to unsightly things like NFS.

If you expect your site to get big or be busy, you will have to come up
with a way (preferably an abstraction on top of pg_lo* functions) that
will preserve the BLOBs in the database so that when you do a reload,
you can pump in the BLOBs as well and connect their *new* OIDs with the
appropriate table.  Because the OIDs will change when you reload.

You do have a backup plan, right?

> plunks itself into my test page as text/plain. How do I get a mime 
> type header associated with this data so my browser will recognize 
> it as a gif or jpeg? 

Store the content type in the database along with the file data. When
you pull it out, use:

        header("Content-type: $mime");

       ,,,
      (. .)
+--ooO-(_)-Ooo------------ --- -- - - -  -
| Stephen van Egmond  http://bang.dhs.org/





view thread (16+ messages)  latest in thread

Message-ID: <20001128132923.B30495@bang.dhs.org>
Permalink:  ../20001128132923.B30495@bang.dhs.org/
Also on:    postgresql.org/message-id/20001128132923.B30495@bang.dhs.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-php@postgresql.org
  Cc: svanegmond@bang.dhs.org, chriswood@wvda.com
  Subject: Re: Question re large objects
  In-Reply-To: <20001128132923.B30495@bang.dhs.org>
  References: <3A23B26E.9056.2942B3@localhost> <20001128132923.B30495@bang.dhs.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox