[Zope] storing binary data in an external database
Christian Theune
ct@gocept.com
Wed, 6 Mar 2002 21:42:10 +0100
Howdi.
On Wed, Mar 06, 2002 at 04:31:42PM -0500, Bryan C. Andregg wrote:
> I need to be able to store images and the like in a postgres table. It would
> seem that <dtml-sqlvar> isn't going to be what I want because there isn't a
> type definition for what I want (the data isn't exactly a string, right?).
>
> I'm reading in the file contents using REQUEST['file'].read(), which works
> great for ascii text files, but not binaries.
Well REQUEST['file'].read() is ok for binaries, just passing it 1to1 through
the database method and adapter may be a bit messy (mixing up sql code aso)
so i prefer to encode (e.g. base64) the binary data so it gets "string-compatible"
and you can safely insert it into your sql method.
>
> Any help appreciated.
> --
> Bryan C. Andregg Duke University Medical Center
> Programmer Dept. of Anesthesiology
> e <bryan.andregg@duke.edu>
> p +1 919 684 6201
Greetings
Christian
--
Christian Theune - ct@gocept.com
gocept gmbh & co.kg - schalaunische strasse 6 - 06366 koethen/anhalt
tel.+49 3496 3099112 - fax.+49 3496 3099118 mob. - 0178 48 33 981
reduce(lambda x,y:x+y,[chr(ord(x)^42) for x in 'zS^BED\nX_FOY\x0b'])