You are better off using FileUpload from the Commons package. Using
DiskFileUpload, you can set a threshold on the size of your files. If the
threshold is breached, the files will be saved in a temp location on your
hard disk from where you can access them as many times as you want. So you
could first save them to the database and then do whatever else you want.
You could even enhance the FileUploadBase to do exactly as you want, i.e,
write to the database and then still give you a handle on a perhaps new
input stream.

--
Vikram


----- Original Message ----- 
From: "Craig R. McClanahan" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <[EMAIL PROTECTED]>
Sent: Friday, October 03, 2003 3:11 PM
Subject: Re: how to read uploaded FormFile InputStream multiple times?


> Ralf Hauser wrote:
>
> >Hi,
> >
> >we use the <html:file to upload also large attachments into a web-mail
> >application.
> >First we put it into the database, but immediately thereafter, we would
like
> >to send it off to multiple recipients via encrypted mail.
> >
> >We get a "Bad File Descriptor" when trying to access the data for a
second
> >time after putting it into the database.
> >doing a inputStream.reset() gives a "java.io.IOException: mark/reset not
> >supported".
> >If we wipe the attachment from the session and get it from the (MySQL)
> >database again, reset() works beautifully and we can read it many times.
But
> >going back and forth to the database is a big waste if the InputStreams
get
> >large.
> >
> >Therefore my request to enhance the documentation in
>
>http://jakarta.apache.org/struts/api/org/apache/struts/upload/FormFile.html
#
> >getInputStream(): how can one use such an InputStream multiple times?
> >
> >Many thanks for any hints!
> >
> >
> Your best bet is to assume that you cannot *ever* read the same input
> stream more than once.  There is no guarantee in the servlet spec that
> this is possible, and it would be prohibitively expensive for a
> container to make such a guarantee, so this is not really a Struts isse
> or even a commons-fileupload issue.  It's an unwarranted assumption that
> you are making -- and such assumptions are more likely than not to be
> non-portable.
>
> The only sane thing to do is to make sure that your *application* has
> stored the uploaded file data where your *application* can find it
> again.  Expecting reset() to work is pretty much guaranteed to cause
> your application to fail.
>
> Note the emphasis in the above paragraph -- this is primarily an
> application issue, not a framework issue or a container issue.
>
> > Ralf ([EMAIL PROTECTED])
> >
> >
> Craig
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to