[Zope] Zope & Postgres with Images

Oleg Broytmann Oleg Broytmann <phd@phd.pp.ru>
Wed, 31 Oct 2001 20:02:00 +0300


On Wed, Oct 31, 2001 at 11:57:43AM -0800, Karl Munroe wrote:
> I am trying to develope a db application that uses a postgres backend.
> 
> 1) I want to store images in postgres db. Anyone figured how to do this?
> (Postgres does not have a built in type such as BLOB in mysql to store
> binary data)

   I think Postgres 7.1 eliminated restrictions on field size (that is, any
field can be BLOB).

> 2) Assuming that I have one figured out....how next do I render the images
> extracted from the db to a webpage through zope?

   In HTML put <img src="/path/to/script?id=...">

   And in the script do:

   SELECT image FROM images WHERE id=... (ZSQL Method, of course)

   RESPONSE.setHeader("Content-Type", "image/png")
   RESPONSE.write(image)

Oleg.
-- 
     Oleg Broytmann     http://www.zope.org/Members/phd/     phd@phd.pp.ru
           Programmers don't die, they just GOSUB without RETURN.