Re: Storing jpgs - Mailing list pgsql-general

From scott.marlowe
Subject Re: Storing jpgs
Date
Msg-id Pine.LNX.4.33.0404051057390.13872-100000@css120.ihs.com
Whole thread Raw
In response to Storing jpgs  ("C G" <csgcsg39@hotmail.com>)
List pgsql-general
On Mon, 5 Apr 2004, C G wrote:

> Dear All,
>
> What's the best way to store jpgs in postgresql to use in a web page?
>
> I tried to use large objects, but how would you extract them from a table to
> be viewed in a web-page without having to write them to a scratch file
> somewhere first?

There are several ways to skin this cat, and your choice depends largely
on what type of system you'll be deploying.

Will you have more than one front end server?  If so, will they be able to
share a network file system mount for the files?  Then the preferred
method for many people is to store the jpg in the file system with a path
in the database.  If you can't mount the same point from multiple servers
(or don't want to) then you'll need to store them in the database.

However, maybe you want to be able to update multiple jpegs at the same
time in a transaction?  then storing them in either a bytea field or
base64 encoded in a text field will work well.

Storing them as base64 or as a path with a file system is likely more
portable than using large objects.  Also, you have to dump large
objects seperately, so your backup process may be more complicated than
you want.

As for displaying them whether you store them as bytea, base64 encoded
text, or large objects, most languages will allow you to build and deliver
an image without having to write it to some temporary place.

Here's a simple example from PHPBuilder on doing it with the file path in
the database, and using a directory of files that may lie outside the
documentroot of apache:

http://www.phpbuilder.com/board/showthread.php?s=&postid=10497815#post10497815


pgsql-general by date:

Previous
From: "Rod K"
Date:
Subject: Re: Storing jpgs
Next
From: Lamar Owen
Date:
Subject: Re: RPM init-script: Why the locale setting?