I have never had luck doing it this way.  Does the file data have to be in
the database?
What I have done is save the file as a file and store a URL to it in an
entity bean (along with whatever metadata I need about the file.)  As I
don't do any filtering or other transformation of the file data, it is
enough for the entity bean to let the servlet or jsp know the URL and let
the web server stream it.
This sort-of obeys the EJB 2 dictum that the beans not do file io (only the
servlet does.)

----- Original Message -----
From: "elephantwalker" <[EMAIL PROTECTED]>
To: "Orion-Interest" <[EMAIL PROTECTED]>
Sent: Monday, July 23, 2001 10:06 AM
Subject: cmp and saving a file to a blob


> Problem, persisting a downloaded file in a cmp ejb.
>
> Has anybody solved this problem? It seems like this is a problem not
solved
> by the specification.
>
> A plan of attack:
>
> 1. web user uploads file through a form.
> 2. servlet processes file as an ArrayList of bytes with Nick Newman's
> servlet (www.orionsupport.com/articles/downloads/UploadServlet.zip) with
> some modifications.
> 3. file (now a List) is a member of a cmp bean with a list type Byte.
>
> If we use this method, each byte is stored in a separate table. Kindof
ugly.
> Talk about a large table!
>
> B plan of attack:
>
> 1. web user uploads file through a form.
> 2. servlet processes file as a byte array with Nick Newman's servlet
> (www.orionsupport.com/articles/downloads/UploadServlet.zip).
> 3. A class called FileBytes is created which implements Serializable, the
> only member is the byte array.
> 4. A cmp ejb with members mimetype, name, datetime, and filebytes.
>
> Both of these methods require no hacking of the orion-ejb-jar.xml. We
would
> have to be satisfied with sql type long raw for most databases, however,
> since the ejb spec doesn't include blobs. This means a limit of 2 GB...not
> enough for a movie, but plenty large enough for anything else. Obviously
we
> should limit the size of the file, since all of the bytes have to be in
> memory. Otherwise, we can break up the persitance into many 1 MB ejb's,
each
> with part of the file. This way, we don't have to have the file all in
> memory at once.
>
> If anybody has done this, let me know. I would like to hear some comments,
> also. I will keep you posted on my experiences.
>
> Regards,
>
> the elephantwalker
>
>
>
>


Reply via email to