Search Postgresql Archives

Re: Storing jpgs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


---------------------------(end of broadcast)---------------------------
TIP 6: Have you searched our list archives?

               http://archives.postgresql.org

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux