Yes, I have commons-fileupload-1.1.1.jar and its dependent jar file commons-io-1.3.1.jar.

In fact, I´ve uploaded files from the two ways I explained in my first mail, but I don´t know which one is better (Struts upload file or commons upload file) due to the disadvantages I´ve found for every one and that I´ve put forward.

From: "Martin Gainty" <[EMAIL PROTECTED]>
Reply-To: "Martin Gainty" <[EMAIL PROTECTED]>
To: "Struts Users Mailing List" <user@struts.apache.org>
Subject: Re: File Upload design doubt
Date: Sun, 18 Feb 2007 15:24:43 -0500

Francisco
with regards to commons-file upload did you upload the latest fileupload.jar into your webapp/AppName/WEB-INF/lib ?
http://jakarta.apache.org/site/downloads/downloads_commons-fileupload.cgi
M-
---------------------------------------------------------------------------
This e-mail message (including attachments, if any) is intended for the use of the individual or entity to which it is addressed and may contain information that is privileged, proprietary , confidential and exempt from disclosure. If you are not the intended recipient, you are notified that any dissemination, distribution or copying of this communication is strictly prohibited.
---------------------------------------------------------------------------
Le présent message électronique (y compris les pièces qui y sont annexées, le cas échéant) s'adresse au destinataire indiqué et peut contenir des renseignements de caractère privé ou confidentiel. Si vous n'êtes pas le destinataire de ce document, nous vous signalons qu'il est strictement interdit de le diffuser, de le distribuer ou de le reproduire.
----- Original Message -----
From: "Francisco Exposito Aguilera" <[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Sunday, February 18, 2007 2:20 PM
Subject: File Upload design doubt


> Hello all,
>
> I am trying to upload files, but I have some doubts.
>
> As I´ve read, there are two typical ways to do that:
>
> 1.Using StrutsFileUpload
>
>                MyActionForm myForm = (MyActionForm)form;
> FormFile myFile = myForm.getMyFile();
> String fileName    = myFile.getFileName();
> String filePath = "G:/FILES/";
>
> File fileToCreate = new File(filePath, fileName);
> InputStream stream = myFile.getInputStream();
> BufferedInputStream in = new BufferedInputStream(stream);
>                BufferedOutputStream out = new BufferedOutputStream(new
> FileOutputStream(fileToCreate));
>
> byte[] bytes = new byte[1048576];
>                int len = 0;
>
>                while ( (len = in.read( bytes )) > 0 )
>                {
>                     out.write( bytes, 0, len );
>                }
>
>                out.close();
>                in.close();
>                stream.close();
> myFile.destroy();
>
> 2.Using Jakarta Commons FileUpload
>
>               DiskFileItemFactory factory = new DiskFileItemFactory();
>               factory.setSizeThreshold(4096);
>               factory.setRepository(new File("G:/FICHEROS/TEMP"));
>               ServletFileUpload upload = new ServletFileUpload(factory);
>
>               upload.setSizeMax(2000000000);
>               List fileItems = upload.parseRequest(request);
>               Iterator i = fileItems.iterator();
>               FileItem fi = (FileItem)i.next();
>               String path="G:/FILES/";
>               String fileName = fi.getName();
>
>               int lastCharacter = fileName.lastIndexOf("\\");
>               String title =
> fi.getName().substring(lastCharacter+1,fi.getName().length());
>               fi.write(new File(path, title));
>
>
> Everyone has its disadvantages:
>
> 1) the struts file upload is slower than the commons file upload: until the > tmp file is completed, all is equitable. But the difference comes with lines
>
> fi.write(new File(path, title));
>
> and
>
> byte[] bytes = new byte[1048576];
> int len = 0;
> while ( (len = in.read( bytes )) > 0 )
> {
>      out.write( bytes, 0, len );
> }
>
> I´ve tried to upload a 200MB file and it takes 1'20" with commons and 2'5"
> with struts. Is there any option to make struts upload file faster?
>
> 2) The commons file upload cannot be used inside an action. It must be an
> independent servlet.
>
>
>
> As well as saving a file in the server (not in the database), I want to save > some info in the database. That is info of the file and of the person who
> save it.
> Here is the decision, but I don´t know which is the better one:
>
> 1) Use Struts fileUpload: Create a form with all fields I need and the input
> file field and an action.
> 2) Use Commons fileUpload: Create a form with all fields, but the input
> file. Save all the info in the database and open then the servlet with the
> file field. Save the file and if something wrong happens, delete the
> database info saved in the last page (if it is possible).
> 3) Any idea???
>
>
> Thanks a lot.
> Best regards,
> Paco
>
> _________________________________________________________________
> Acepta el reto MSN Premium: Protección para tus hijos en internet.
> Descárgalo y pruébalo 2 meses gratis.
> http://join.msn.com?XAPID=1697&DI=1055&HL=Footer_mailsenviados_proteccioninfantil
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

_________________________________________________________________
Descarga gratis la Barra de Herramientas de MSN http://www.msn.es/usuario/busqueda/barra?XAPID=2031&DI=1055&SU=http%3A//www.hotmail.com&HL=LINKTAG1OPENINGTEXT_MSNBH


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

Reply via email to