Can you elaborate on this some more? I followed through the example here: http://www.roseindia.net/struts/strutsfileupload.shtml.
My ActionForm has a property of FormFile called myFile. Once I'm inside the Action class, the file upload has already taken place (part of processPopulate?). That is, I can see the temp file in the tempDir folder (set in struts-config.xml controller element), and this code inside my action executes: // Process the FormFile FormFile myFile = myForm.getTheFile(); String contentType = myFile.getContentType(); String fileName = myFile.getFileName(); int fileSize = myFile.getFileSize(); byte[] fileData = myFile.getFileData(); System.out.println("contentType: " + contentType); System.out.println("File Name: " + fileName); System.out.println("File Size: " + fileSize); The problems at this point are: 1. The file already exists in the OS since the DeferredFileOutputStream wrote it once it reached the default size of 256*1024 (256K) 2. I'd like to get that file and run a virus scanner against it manually (McAfee excludes this folder so the file doesn't get removed) 3. I CAN write another piece of code to copy this inputStream to another file, but then that's going to add another 8-10 seconds when the files get larger (80 MB). And, the file is already there, it's just that the FormFile interface doesn't expose the FileItem from the CommonsFormFile (I think that's the name of the inner class inside the CommonsMultipartRequestHandler). 4. I'll assume that the byte[] is really not the way to process a large file because I've already run into problems with that. 5. Once the scan has taken place, I want to save the file to a BLOB in an Oracle database. -----Original Message----- From: Martin Gainty [mailto:[EMAIL PROTECTED] Sent: Monday, October 23, 2006 3:23 PM To: Struts Users Mailing List Subject: Re: Re: FormFile getPath() ? Eric you'll need to implement FileItem e.g. public final class UploadAction extends Action implements org.apache.commons.fileupload.FileItem Martin -- This e-mail communication and any attachments may contain confidential and privileged information for the use of the designated recipients named above. If you are not the intended recipient, you are hereby notified that you have received this communication in error and that any review, disclosure, dissemination, distribution or copying of it or its contents ----- Original Message ----- From: "Givler, Eric" <[EMAIL PROTECTED]> To: "Struts Users Mailing List" <user@struts.apache.org> Sent: Monday, October 23, 2006 2:19 PM Subject: RE: Re: FormFile getPath() ? 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. It appears that CommonsMultipartRequestHandler processes the request and adds FormFile elements for each file that is found to a Hash table, but these elements are of type CommonsFile, and don't give access to the fileItem, which might be able to give me the temporary filename. -----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] --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]