db-torque-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bill Schneider <bschnei...@vecna.com>
Subject Re: How to read/write images to/from db
Date Wed, 19 Mar 2003 14:27:17 GMT
to display the image you would write a servlet that returns the right
content type (image/gif, image/jpeg, etc.), reads the byte[] from the db
with Torque, and outputs the byte[] contents to the ServletOutputStream.

To upload an image, you would use a multipart form with an input type=file.
Check out Struts to see an example of how to handle uploaded files on the
server.  Somewhere in your own process-upload action you would get a byte[]
with the contents of the uploaded file, and pass it to setPicture(byte[]).

-- Bill
----- Original Message -----
From: "Michael Schmitt" <mi.schmitt@gmx.de>
To: <torque-user@db.apache.org>
Sent: Wednesday, March 19, 2003 8:11 AM
Subject: How to read/write images to/from db

> Hi,
> probably, this is not the right mailing list for my question, but since I
> use Torque to access the data, I hope that someone may answer my
> question.
> My schema schema definition looks something like this:
> ...
>   <table name="item">
>     <column name="id" required="true" type="INTEGER" primaryKey="true"/>
>     ...
>     <column name="picture" required="false" type="BLOB"/>
> </table>
> ....
> (db: MySql)
> I want to write a JSP/Servlet (running on tomcat 4.1.18) that shows the
> details
> and the image of an 'Item'. But I don't know how to get the image from the
> db.
> Do I have to write a servlet that delivers the image? If so, how to write
> it?
> Also, I want to offer another JSP/HTML or whatever that enables a user to
> upload the image. But I don't know to upload and how to write it to the
> The
> generated Java-class offers the method 'setPicture(byte[])', but where to
> get the
> byte[] from?
> Any help will be welcomed,
> michael
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: torque-user-unsubscribe@db.apache.org
> For additional commands, e-mail: torque-user-help@db.apache.org

View raw message