This is a little example :

response.setHeader("Content-Disposition",
       "attachment; filename=\"" + part.getFileName()
         + "\"");
     response.setContentType(part.getContentType());
     InputStream instream = part.getInputStream();
     ServletOutputStream outstream = response.getOutputStream();

     int b = 0;
     while (b != -1) {

      b = instream.read();
      outstream.write(b);

     }
     instream.close();
     outstream.close();


WHERE part.getFileName() sustitute by the Filename of the File,
              part.getContentType() sustitute the ContentType of the File
              part.getInputStream(); sustitute the Stream Data of the File.


That's all!






----- Original Message -----
From: "Grzegorz Stasica" <[EMAIL PROTECTED]>
To: <user@struts.apache.org>
Sent: Wednesday, May 11, 2005 9:30 PM
Subject: Re: how to download file (example)


> Frank W. Zammetti wrote:
> > Hello,
> >
> > Do you want to use the Struts DownloadAction?  If so, have a look here:
> >
> > http://wiki.apache.org/struts/StrutsFileDownload
> >
> > Even if you don't want to use it, you may find the example helpful,
along
> > with the source for DownloadAction, to help you along.
> >
> Unfortunatelly I am running struts 1.2.4. DownloadActioni will be
> available in 1.2.6 version which at this moment is in beta phase
>
>
> ---------------------------------------------------------------------
> 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