Did you ever get a solution to this?  

The filename from FormFile.getFileName() is the client file name, right?

My requirement is that the uploads can be up to 100MB, and I can see the file 
created in a temp folder (rather quickly).  Before I can load it into the 
database, I have to run a virus scanner against it.  So creating another copy 
of the file is an extra step for me as well.

-----Original Message-----
From: Laurent Duparchy [mailto:[EMAIL PROTECTED]
Sent: Monday, October 02, 2006 4:11 AM
To: Struts Users Mailing List
Subject: Re: FormFile getPath() ?


Hi,

thanks but the reply but I think it does exactly what I want to avoid 
(and what I'm currenlty doing) : Create a second temp file by reading 
the inputsream into a new FileOutputStream.

I'm looking into the possibility to get the filepath (when exist) of the 
FormFile, not the inpustream.


Mark Shifman wrote:

> An action like this should do it:
> public final class UploadAction extends Action {
>    public ActionForward execute( ActionMapping mapping, ActionForm form,
>        HttpServletRequest request, HttpServletResponse response)  
> throws Exception {
>
>        UploadForm theForm = (UploadForm) form;
>        FormFile file = theForm.getTheFile();
>        String fileName = file.getFileName();
>
>        try {
>                String filePath =
>                    tempdir + "/" + fileName;
>                //retrieve the file data
>
>                InputStream stream = file.getInputStream();
>
>                //write the file to the file specified
>                OutputStream bos = new FileOutputStream(filePath);
>                int bytesRead = 0;
>                byte[] buffer = new byte[8192];
>                while ((bytesRead = stream.read(buffer, 0, 8192)) != -1) {
>                    bos.write(buffer, 0, bytesRead);
>                }
>                bos.close();
>                //close the stream
>                stream.close();
>        } catch (Exception ex) {
>                  throw ex;
>        }
>
>        file.destroy();
>
>        return (mapping.findForward("anywhereyouwant");
>
>    }
>       Laurent Duparchy wrote:
>
>> Hi,
>>
>> My front-end program upload files and then forward the file path to 
>> another server side program that handle them.
>>
>> The problem is that I have to read the FormFile data and store it 
>> into another temp file.
>>
>> It would increase performances this data duplication and have access 
>> directly to the Struts temp file.
>>
>> I can't see how.
>>
>> I understand that there is maybe no file at all, as a small size a 
>> file will be stored in memory, but is the maybe existing underlying 
>> FileItem avaiable in anyway ?
>>
>> Laurent
>>
>>
>> ---------------------------------------------------------------------
>> 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]


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

Reply via email to