Re: Streaming a huge ZIP file

2007-12-17 Thread Johan Compagner
you can't update a page and download in 1 request.
You have to do this in 2. First update the page that does a call back to the
server when loaded that loads the resource

johan



On Dec 17, 2007 9:40 AM, Gabor Szokoli [EMAIL PROTECTED] wrote:

 Hi,

 This looks completely straight-forward, we'll switch to it as soon as
 move to rc3.

 On Dec 16, 2007 8:33 PM, Johan Compagner [EMAIL PROTECTED] wrote:

  RequestCycle.get().setRequestTarget(new
 ResourceStreamRequestTarget(writer,
  test.zip));

 Maybe this is dumb, but if I encounter an exception in the write
 method (during content generation), can I unsnatch the stream and
 hand it back to wicket for displaying regular pages? I realise the
 headers like content type and even some content might have been
 streamed out already, but who knows.

 Slightly related, what would be the best way for a single onclick()
 event to result in both a wicket page refresh and a download?


 Gabor Szokoli

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




Re: Streaming a huge ZIP file

2007-12-16 Thread Johan Compagner
Stupid me of not knowing anymore what i committed myself

AbstractResourceStreamWriter writer = new AbstractResourceStreamWriter()
{
write(OutputStream output)
{
   // do your generation and output
}
};
RequestCycle.get().setRequestTarget(new ResourceStreamRequestTarget(writer,
test.zip));
johan

P.S. not everything of this example is yet in a release (will be 1.3rc3)
On Dec 13, 2007 1:16 AM, Gabor Szokoli [EMAIL PROTECTED] wrote:

 On Dec 12, 2007 11:58 PM, Igor Vaynberg [EMAIL PROTECTED] wrote:
  ((WebResponse)r.getResponse).setAttachmentHeader(foo.xls);

 Indeed!
 Thank you.


 Gabor Szokoli

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




Re: Streaming a huge ZIP file

2007-12-12 Thread Gabor Szokoli
Thanks all!

On Dec 12, 2007 8:48 AM, Thomas Singer [EMAIL PROTECTED] wrote:
 IIRC, DownloadLink and Igor's anonymous class will lock the session, so if
 you have one downloading over a very slow connection, other users will get a
 timeout.

I beleive I have separate sessions for each user, so only the same
users other tabs would experience unresponsiveness, right?

We'll test and report back soon.

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



Streaming a huge ZIP file

2007-12-11 Thread Gabor Szokoli
Hi there,

The downside of an easy-to-use framework is the influx of users with
little understanding of the underlying servlet technology, like me.
Observe:

I'd like to provide a ZIP file (could be TAR, anything Windows PCs can
save and later extract from) as a download, one that is potentially
too big to be kept in memory in full.
So I guess I'd need to stream it in chunks, or as a java stream or channel.
Can I do that from wicket?
Or does the servlet interface require a fully assembled response in memory?

Currently I assemble the ZIP file in a byte array in full, but it
feels awkward. Would extending WebResource fit the bill?

ByteArrayOutputStream bout = new 
ByteArrayOutputStream();
ZipOutputStream zout = new ZipOutputStream(bout);
// Add entries
zout.finish();
zout.close();

Resource resource = new 
ByteArrayResource(application/zip,
bout.toByteArray());
ResourceStreamRequestTarget target = new
ResourceStreamRequestTarget(resource.getResourceStream());
target.setFileName(new
SimpleDateFormat(MMddHHmmss).format(Calendar.getInstance().getTime())
+ .zip);
getRequestCycle().setRequestTarget(target);


All suggestions are welcome.


Gabor Szokoli

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



Re: Streaming a huge ZIP file

2007-12-11 Thread Gabor Szokoli
I guess I forgot to mentionthe single most important aspect of my question:
The archive not present on the file system, it is dynamically
assembled on the fly from individual files.
(the whole point is downloading multiple files in one go.)


Gabor Szokoli

On Dec 11, 2007 11:45 PM, Jeremy Levy [EMAIL PROTECTED] wrote:
 Gabor,

 Try DownloadLink
 http://wicket.sourceforge.net/apidocs/wicket/markup/html/link/DownloadLink.html

 J


 On Dec 11, 2007 5:39 PM, Gabor Szokoli [EMAIL PROTECTED] wrote:

  Hi there,
 
  The downside of an easy-to-use framework is the influx of users with
  little understanding of the underlying servlet technology, like me.
  Observe:
 
  I'd like to provide a ZIP file (could be TAR, anything Windows PCs can
  save and later extract from) as a download, one that is potentially
  too big to be kept in memory in full.
  So I guess I'd need to stream it in chunks, or as a java stream or
  channel.
  Can I do that from wicket?
  Or does the servlet interface require a fully assembled response in
  memory?
 
  Currently I assemble the ZIP file in a byte array in full, but it
  feels awkward. Would extending WebResource fit the bill?
 
 ByteArrayOutputStream bout = new
  ByteArrayOutputStream();
 ZipOutputStream zout = new ZipOutputStream(bout);
 // Add entries
 zout.finish();
 zout.close();
 
 Resource resource = new
  ByteArrayResource(application/zip,
  bout.toByteArray());
 ResourceStreamRequestTarget target = new
  ResourceStreamRequestTarget(resource.getResourceStream());
 target.setFileName(new
  SimpleDateFormat(MMddHHmmss).format(Calendar.getInstance
  ().getTime())
  + .zip);
 getRequestCycle().setRequestTarget(target);
 
 
  All suggestions are welcome.
 
 
  Gabor Szokoli
 
  -
  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]



Re: Streaming a huge ZIP file

2007-12-11 Thread Igor Vaynberg
getrequestcycle().setrequesttarget(new irequesttarget() {
respond(response r) { outputstream out=r.getoutputstream(); stream
your date into out; }}}

-igor


On Dec 11, 2007 2:52 PM, Gabor Szokoli [EMAIL PROTECTED] wrote:
 I guess I forgot to mentionthe single most important aspect of my question:
 The archive not present on the file system, it is dynamically
 assembled on the fly from individual files.
 (the whole point is downloading multiple files in one go.)


 Gabor Szokoli


 On Dec 11, 2007 11:45 PM, Jeremy Levy [EMAIL PROTECTED] wrote:
  Gabor,
 
  Try DownloadLink
  http://wicket.sourceforge.net/apidocs/wicket/markup/html/link/DownloadLink.html
 
  J
 
 
  On Dec 11, 2007 5:39 PM, Gabor Szokoli [EMAIL PROTECTED] wrote:
 
   Hi there,
  
   The downside of an easy-to-use framework is the influx of users with
   little understanding of the underlying servlet technology, like me.
   Observe:
  
   I'd like to provide a ZIP file (could be TAR, anything Windows PCs can
   save and later extract from) as a download, one that is potentially
   too big to be kept in memory in full.
   So I guess I'd need to stream it in chunks, or as a java stream or
   channel.
   Can I do that from wicket?
   Or does the servlet interface require a fully assembled response in
   memory?
  
   Currently I assemble the ZIP file in a byte array in full, but it
   feels awkward. Would extending WebResource fit the bill?
  
  ByteArrayOutputStream bout = new
   ByteArrayOutputStream();
  ZipOutputStream zout = new ZipOutputStream(bout);
  // Add entries
  zout.finish();
  zout.close();
  
  Resource resource = new
   ByteArrayResource(application/zip,
   bout.toByteArray());
  ResourceStreamRequestTarget target = new
   ResourceStreamRequestTarget(resource.getResourceStream());
  target.setFileName(new
   SimpleDateFormat(MMddHHmmss).format(Calendar.getInstance
   ().getTime())
   + .zip);
  getRequestCycle().setRequestTarget(target);
  
  
   All suggestions are welcome.
  
  
   Gabor Szokoli
  
   -
   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]



Re: Streaming a huge ZIP file

2007-12-11 Thread Johan Compagner
But still youj could generate to a tmp file onm disk and stream that.
But you xan also generate on the fly and stream that direcly to a
response stream

On 12/11/07, Gabor Szokoli [EMAIL PROTECTED] wrote:
 I guess I forgot to mentionthe single most important aspect of my question:
 The archive not present on the file system, it is dynamically
 assembled on the fly from individual files.
 (the whole point is downloading multiple files in one go.)


 Gabor Szokoli

 On Dec 11, 2007 11:45 PM, Jeremy Levy [EMAIL PROTECTED] wrote:
  Gabor,
 
  Try DownloadLink
 
 http://wicket.sourceforge.net/apidocs/wicket/markup/html/link/DownloadLink.html
 
  J
 
 
  On Dec 11, 2007 5:39 PM, Gabor Szokoli [EMAIL PROTECTED] wrote:
 
   Hi there,
  
   The downside of an easy-to-use framework is the influx of users with
   little understanding of the underlying servlet technology, like me.
   Observe:
  
   I'd like to provide a ZIP file (could be TAR, anything Windows PCs can
   save and later extract from) as a download, one that is potentially
   too big to be kept in memory in full.
   So I guess I'd need to stream it in chunks, or as a java stream or
   channel.
   Can I do that from wicket?
   Or does the servlet interface require a fully assembled response in
   memory?
  
   Currently I assemble the ZIP file in a byte array in full, but it
   feels awkward. Would extending WebResource fit the bill?
  
  ByteArrayOutputStream bout = new
   ByteArrayOutputStream();
  ZipOutputStream zout = new ZipOutputStream(bout);
  // Add entries
  zout.finish();
  zout.close();
  
  Resource resource = new
   ByteArrayResource(application/zip,
   bout.toByteArray());
  ResourceStreamRequestTarget target = new
   ResourceStreamRequestTarget(resource.getResourceStream());
  target.setFileName(new
   SimpleDateFormat(MMddHHmmss).format(Calendar.getInstance
   ().getTime())
   + .zip);
  getRequestCycle().setRequestTarget(target);
  
  
   All suggestions are welcome.
  
  
   Gabor Szokoli
  
   -
   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]



Re: Streaming a huge ZIP file

2007-12-11 Thread Thomas Singer
IIRC, DownloadLink and Igor's anonymous class will lock the session, so if 
you have one downloading over a very slow connection, other users will get a 
timeout.


Cheers,
Tom


Igor Vaynberg wrote:

getrequestcycle().setrequesttarget(new irequesttarget() {
respond(response r) { outputstream out=r.getoutputstream(); stream
your date into out; }}}

-igor


On Dec 11, 2007 2:52 PM, Gabor Szokoli [EMAIL PROTECTED] wrote:

I guess I forgot to mentionthe single most important aspect of my question:
The archive not present on the file system, it is dynamically
assembled on the fly from individual files.
(the whole point is downloading multiple files in one go.)


Gabor Szokoli


On Dec 11, 2007 11:45 PM, Jeremy Levy [EMAIL PROTECTED] wrote:

Gabor,

Try DownloadLink
http://wicket.sourceforge.net/apidocs/wicket/markup/html/link/DownloadLink.html

J


On Dec 11, 2007 5:39 PM, Gabor Szokoli [EMAIL PROTECTED] wrote:


Hi there,

The downside of an easy-to-use framework is the influx of users with
little understanding of the underlying servlet technology, like me.
Observe:

I'd like to provide a ZIP file (could be TAR, anything Windows PCs can
save and later extract from) as a download, one that is potentially
too big to be kept in memory in full.
So I guess I'd need to stream it in chunks, or as a java stream or
channel.
Can I do that from wicket?
Or does the servlet interface require a fully assembled response in
memory?

Currently I assemble the ZIP file in a byte array in full, but it
feels awkward. Would extending WebResource fit the bill?

   ByteArrayOutputStream bout = new
ByteArrayOutputStream();
   ZipOutputStream zout = new ZipOutputStream(bout);
   // Add entries
   zout.finish();
   zout.close();

   Resource resource = new
ByteArrayResource(application/zip,
bout.toByteArray());
   ResourceStreamRequestTarget target = new
ResourceStreamRequestTarget(resource.getResourceStream());
   target.setFileName(new
SimpleDateFormat(MMddHHmmss).format(Calendar.getInstance
().getTime())
+ .zip);
   getRequestCycle().setRequestTarget(target);


All suggestions are welcome.


Gabor Szokoli

-
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]