bradcathey has asked for the wisdom of the Perl Monks concerning the following question:

Fellow Monasterians,

I'm in GGI::Application and using the octet-stream parameter of the header_add method to stream a file download.

This works fine, but after streaming the file, I would like to output another screen dealing with what was just downloaded. Is there a way to return 2 different outputs? Below is a stripped down version of what I have.

package FooBar; use base 'CGI::Application'; use HTML::Template; sub setup { my $self = shift; $self->start_mode('sh'); $self->mode_param('rm'); $self->run_modes('sf' => 'save_file'); } sub save_file { my $self = shift; my $some_file = "This,is,a,test"; $self->header_add( -type =>'application/octet-stream', -attachment => "somefile.csv', -expires =>'0', ); return $some_file; }

Tried this, but all it did was stream the file:

$template = $self->load_tmpl( "foobar.tmpl"); return ($template->output, $some_file);

Ideas? TIA


—Brad
"The important work of moving the world forward does not wait to be done by perfect men." George Eliot

Replies are listed 'Best First'.
Re: After sending file by octet/stream, open new template page
by Fletch (Bishop) on May 16, 2006 at 00:01 UTC

    Can't do that in HTTP. Best you can do is what most download places do (e.g. Sourceforge) and send a refresh with the URL of the content to be downloaded. And of course you'd want to provide a "If this doesn't start in n seconds try this link." link to the same URL in the page.

      Thanks for the confirmation. Our solution was to make visible the appropriate buttons after the user selected the option to download the file. It's a nifty little jaba-the-script solution in a closed system where the much criticized scripting language is required anyway.


      —Brad
      "The important work of moving the world forward does not wait to be done by perfect men." George Eliot