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]



Reply via email to