You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@struts.apache.org by Grzegorz Stasica <gs...@poczta.onet.pl> on 2005/05/11 20:30:15 UTC
how to download file (example)
hi,
I'm looking for links/examples how to download file in struts action. In
action I have OutputStream but what header should I send and the most
important how the stram should be send to browser
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how to download file (example)
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
True... I would however be very willing to bet you can lift the
DownloadAction class from 1.2.6 and drop it in 1.2.4 without any
problem... As a matter of fact, although I'm not 100% certain, I think the
sample app I wrote that you can grab off the Wiki is in fact using
1.2.4... heck, there's a chance it's using 1.1! :)
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
On Wed, May 11, 2005 3:30 pm, Grzegorz Stasica said:
> 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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how to download file (example)
Posted by Fco Javier Jiemnez <da...@tiscali.es>.
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" <gs...@poczta.onet.pl>
To: <us...@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: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how to download file (example)
Posted by Grzegorz Stasica <gs...@poczta.onet.pl>.
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: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org
Re: how to download file (example)
Posted by "Frank W. Zammetti" <fz...@omnytex.com>.
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.
--
Frank W. Zammetti
Founder and Chief Software Architect
Omnytex Technologies
http://www.omnytex.com
On Wed, May 11, 2005 2:30 pm, Grzegorz Stasica said:
> hi,
>
> I'm looking for links/examples how to download file in struts action. In
> action I have OutputStream but what header should I send and the most
> important how the stram should be send to browser
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
> For additional commands, e-mail: user-help@struts.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@struts.apache.org
For additional commands, e-mail: user-help@struts.apache.org