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