[Zope-DB] Help on storing images in Postgresql

CY CY" <cyhoong@pc.jaring.my
Fri, 4 Apr 2003 22:33:50 +0800


This is a multi-part message in MIME format.

------=_NextPart_000_003F_01C2FAFA.43DFBEA0
Content-Type: multipart/alternative;
	boundary="----=_NextPart_001_0040_01C2FAFA.43DFBEA0"


------=_NextPart_001_0040_01C2FAFA.43DFBEA0
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hello

I need some help ins storing .gif & jpeg files in Postgresql.=20

My current server  is running  Zope2.5.1 on RH8.0 with Postgresql7.2.2.

I have create a simple form to capture some digital images for uploading =
to Zope server from my PC (WIn98).
However I encounter an error message (below).
=20
The system is looking for the images in server while the actual image is =
in the PC.  How I do "tell" the system
the location of the image file?

TQ in advance

       Z SQL Method at  /STARS/Photo/uploadPhoto_sql  Help! =20


-------------------------------------------------------------------------=
-------

Error, psycopg.IntegrityError: ERROR: lo_import: can't open unix file =
"g:images=08irds.gif": No such file or directory insert into photo( =
person_id, comments, pic) values ('robert', 'happy bird day', lo_import =
('g:\images\birds.gif') )=20

-------------------------------------------------------------------------=
-------

SQL used:

insert into photo(
  person_id, comments, pic)=20
values
  ('robert',=20
   'happy bird day',
   lo_import ('g:\images\birds.gif')
   )
Photo upload Form
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
<dtml-var standard_html_header><h2><dtml-var title_or_id></h2>
<form action=3D"uploadPhoto_action" method=3D"post"><table>  <tr>     =
<td>Person ID:</td>     <td><input type=3D"text" name=3D"person_id" =
maxlength=3D"16" size=3D"20"></td>  </tr>  <tr>     <td>Comments:</td>   =
  <td><input type=3D"text" name=3D"comments" maxlength=3D"20" =
size=3D"20"></td>  </tr>  <tr>     <td>Filename: </td>     <td><input =
type=3D"file" name=3D"pic" accept=3D"image/*">  </tr>  =
<tr><td>&nbsp;&nbsp;</td></tr>  <tr>     <td align=3D"right"><input =
type=3D"reset" name=3D"submit" value=3D"Reset"></td>     <td><input =
type=3D"submit" name=3D"submit" value=3D"Upload"></td>  </tr>
<dtml-var standard_html_footer>

uploadPhoto_action Method
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=

<dtml-var standard_html_header><h2><dtml-var title_or_id> <dtml-var =
document_title></h2>
 <dtml-call "uploadPhoto_sql       (cust_id=3DREQUEST.get('person_id'),  =
      comments=3DREQUEST.get('comments'),        =
pic=3DREQUEST.get('pic') )">
 <dtml-call "RESPONSE.redirect('uploadPhoto_form')">
<dtml-var standard_html_footer>


------=_NextPart_001_0040_01C2FAFA.43DFBEA0
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT face=3DArial size=3D2>Hello</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I need some help ins storing .gif &amp; =
jpeg files=20
in Postgresql.&nbsp;</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>My current server &nbsp;is running =
&nbsp;Zope2.5.1=20
on RH8.0 with Postgresql7.2.2.</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>I have create a simple form to capture =
some digital=20
images for uploading to Zope server from my PC (WIn98).</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>However I encounter an error message=20
(below).</FONT></DIV>
<DIV><!--StartFragment -->&nbsp;</DIV>
<DIV><FONT face=3DArial size=3D2>The system is looking for the images in =
server=20
while the actual image is in the PC.&nbsp; How I do "tell" the=20
system</FONT></DIV>
<DIV><FONT face=3DArial size=3D2>the location of the image =
file?</FONT><BR></DIV>
<DIV><FONT face=3DArial size=3D2>TQ in advance</FONT></DIV>
<DIV><FONT face=3DArial size=3D2></FONT>&nbsp;</DIV>
<DIV>
<TABLE cellSpacing=3D0 cellPadding=3D2 width=3D"100%" border=3D0>
  <TBODY>
  <TR class=3Dlocation-bar>
    <TD vAlign=3Dtop align=3Dleft>
      <DIV class=3Dstd-text><IMG alt=3D"Z SQL Method"=20
      src=3D"http://lifebook:8080/misc_/ZSQLMethods/sqlmethod.gif" =
border=3D0>=20
      <STRONG>Z SQL Method at <A=20
      href=3D"http://lifebook:8080/manage_workspace">&nbsp;/</A><A=20
      href=3D"http://lifebook:8080/STARS/manage_workspace">STARS</A>/<A=20
      =
href=3D"http://lifebook:8080/STARS/Photo/manage_workspace">Photo</A>/<A=20
      class=3Dstrong-link=20
      =
href=3D"http://lifebook:8080/STARS/Photo/uploadPhoto_sql/manage_workspace=
">uploadPhoto_sql</A>=20
      </STRONG></DIV></TD>
    <TD vAlign=3Dtop align=3Dright>
      <DIV class=3Dstd-text><A=20
      onmouseover=3D"window.status=3D'Open online help'; return true;"=20
      =
onclick=3D"window.open('http://lifebook:8080/HelpSys?help_url=3D/Control_=
Panel/Products/ZSQLMethods/Help/Z-SQL-Method_Edit.stx','zope_help','width=
=3D600,height=3D500,menubar=3Dyes,toolbar=3Dyes,scrollbars=3Dyes,resizabl=
e=3Dyes').focus(); return false;"=20
      onmouseout=3D"window.status=3D''; return true;"=20
      =
href=3D"http://lifebook:8080/HelpSys?help_url=3D/Control_Panel/Products/Z=
SQLMethods/Help/Z-SQL-Method_Edit.stx">Help!</A>=20
      </DIV></TD></TR></TBODY></TABLE></DIV>
<DIV>
<HR>
</DIV>
<DIV><STRONG>Error, <EM>psycopg.IntegrityError</EM>:</STRONG> ERROR: =
lo_import:=20
can't open unix file "g:images=08irds.gif": No such file or directory =
insert into=20
photo( person_id, comments, pic) values ('robert', 'happy bird day', =
lo_import=20
('g:\images\birds.gif') ) </DIV>
<DIV>
<HR>
</DIV>
<DIV><STRONG>SQL used:</STRONG><BR></DIV><PRE>insert into photo(
  person_id, comments, pic)=20
values
  ('robert',=20
   'happy bird day',
   lo_import ('g:\images\birds.gif')
   )</PRE><PRE>Photo upload =
Form</PRE><PRE>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D</PR=
E><PRE>&lt;dtml-var standard_html_header&gt;<BR>&lt;h2&gt;&lt;dtml-var =
title_or_id&gt;&lt;/h2&gt;</PRE><PRE>&lt;form =
action=3D"uploadPhoto_action" =
method=3D"post"&gt;<BR>&lt;table&gt;<BR>&nbsp; =
&lt;tr&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &lt;td&gt;Person =
ID:&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &lt;td&gt;&lt;input =
type=3D"text" name=3D"person_id" maxlength=3D"16" =
size=3D"20"&gt;&lt;/td&gt;<BR>&nbsp; &lt;/tr&gt;<BR>&nbsp; =
&lt;tr&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
&lt;td&gt;Comments:&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
&lt;td&gt;&lt;input type=3D"text" name=3D"comments" maxlength=3D"20" =
size=3D"20"&gt;&lt;/td&gt;<BR>&nbsp; &lt;/tr&gt;<BR>&nbsp; =
&lt;tr&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &lt;td&gt;Filename: =
&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &lt;td&gt;&lt;input =
type=3D"file" name=3D"pic" accept=3D"image/*"&gt;<BR>&nbsp; =
&lt;/tr&gt;<BR>&nbsp; =
&lt;tr&gt;&lt;td&gt;&amp;nbsp;&amp;nbsp;&lt;/td&gt;&lt;/tr&gt;<BR>&nbsp; =
&lt;tr&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; &lt;td =
align=3D"right"&gt;&lt;input type=3D"reset" name=3D"submit" =
value=3D"Reset"&gt;&lt;/td&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp; =
&lt;td&gt;&lt;input type=3D"submit" name=3D"submit" =
value=3D"Upload"&gt;&lt;/td&gt;<BR>&nbsp; =
&lt;/tr&gt;</PRE><PRE>&lt;dtml-var standard_html_footer&gt;</PRE><PRE>
uploadPhoto_action =
Method</PRE><PRE>=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D</PRE><PRE>&lt;dtml-var =
standard_html_header&gt;<BR>&lt;h2&gt;&lt;dtml-var title_or_id&gt; =
&lt;dtml-var document_title&gt;&lt;/h2&gt;</PRE><PRE>&nbsp;&lt;dtml-call =
"uploadPhoto_sql<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; =
(cust_id=3DREQUEST.get('person_id'),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nb=
sp;&nbsp; =
comments=3DREQUEST.get('comments'),<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbs=
p;&nbsp; pic=3DREQUEST.get('pic') )"&gt;</PRE><PRE>&nbsp;&lt;dtml-call =
"RESPONSE.redirect('uploadPhoto_form')"&gt;</PRE><PRE>&lt;dtml-var =
standard_html_footer&gt;</PRE></BODY></HTML>

------=_NextPart_001_0040_01C2FAFA.43DFBEA0--

------=_NextPart_000_003F_01C2FAFA.43DFBEA0
Content-Type: image/gif;
	name="sqlmethod.gif"
Content-Transfer-Encoding: base64
Content-Location: http://lifebook:8080/misc_/ZSQLMethods/sqlmethod.gif

R0lGODlhEAAQAPcAAP8A/wAAAFBQUICAgMDAwP8AAIAAQAAAoABAgIAAgEAAQP//AP//gACAgECA
gP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA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