You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Alex Rass <ar...@itbsllc.com> on 2010/06/15 12:24:05 UTC
RE: Creating and zipping binary files for download
You should consider that 2 users can be doing it at the same time.
Which will lead to serious errors.
I would suggest using a random file name (or one with session hash in the
filename) so you avoid userA downloading userB's download.zip
I would think that you should be able to just stream it right back to the
client as a redirect or smth. This temporary file thing seems very improper.
- Alex
-----Original Message-----
From: Alex Zeit [mailto:zeitalex@googlemail.com]
Sent: Sunday, May 30, 2010 7:30 AM
To: users@wicket.apache.org
Subject: Re: Creating and zipping binary files for download
Thank you very much Jeremy for your help. As you suggested I create
temporary dir and place files there.
Wicket is really great! The solution to my problem was just in couple of
lines of code:
org.apache.wicket.util.file.File wdir = new
org.apache.wicket.util.file.File(createTempDirectory());
ZipResourceStream zrs = new ZipResourceStream(wdir);
ResourceStreamRequestTarget target = new
ResourceStreamRequestTarget(zrs, "download.zip");
RequestCycle.get().setRequestTarget(target);
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org
Re: Creating and zipping binary files for download
Posted by Alex Zeit <ze...@googlemail.com>.
Thank you very much for your suggestions. I was also thinking of creating
folders with random names.
I am using geotools libs to generate shapefiles set that I want to zip and
stream back.
I did not figure out yet how can I generate those files to stream using
Geotools.
2010/6/15 Jeremy Thomerson <je...@wickettraining.com>
> On Tue, Jun 15, 2010 at 5:24 AM, Alex Rass <ar...@itbsllc.com> wrote:
>
> > You should consider that 2 users can be doing it at the same time.
> > Which will lead to serious errors.
> > I would suggest using a random file name (or one with session hash in the
> > filename) so you avoid userA downloading userB's download.zip
> >
> > I would think that you should be able to just stream it right back to the
> > client as a redirect or smth. This temporary file thing seems very
> > improper.
> >
> > - Alex
> >
>
> You don't even have to do all that random naming stuff yourself. Just use
> a
> Resource that's local to the user's session and Wicket will create the URL
> for you. That also saves him from having to write it out to a file at all
> -
> he can just stream it back if desired.
>
> --
> Jeremy Thomerson
> http://www.wickettraining.com
>
Re: Creating and zipping binary files for download
Posted by Jeremy Thomerson <je...@wickettraining.com>.
On Tue, Jun 15, 2010 at 5:24 AM, Alex Rass <ar...@itbsllc.com> wrote:
> You should consider that 2 users can be doing it at the same time.
> Which will lead to serious errors.
> I would suggest using a random file name (or one with session hash in the
> filename) so you avoid userA downloading userB's download.zip
>
> I would think that you should be able to just stream it right back to the
> client as a redirect or smth. This temporary file thing seems very
> improper.
>
> - Alex
>
You don't even have to do all that random naming stuff yourself. Just use a
Resource that's local to the user's session and Wicket will create the URL
for you. That also saves him from having to write it out to a file at all -
he can just stream it back if desired.
--
Jeremy Thomerson
http://www.wickettraining.com