views:

215

answers:

2

Hi,

I am using the Stream (qw/stream_file/) Plugin for CGI::Application within a runmode to read a file from the filesystem and stream it back to the user.

The user clicks on a link whose "id" attribute I use in an ajax call using Jquery to fetch the file (/?mode=get_file&fileid=<someid>).

I am also using the Jquery taconite plugin to update page contents in other parts of my application; but I do not return any xml in the get_file runmode, which looks like this:


sub get_file{
  my $self = shift;
  my $fileid=$self->query->param("fileid");
  $self->header_add( -attachment => $fileid );
  $self->header_add( -type => "application/x-download");
  if ( $self->stream_file( $fileid ) ) {
        return;
  } else {
        return $self->error_mode();
  }
}

The result is:

  • The file does get streamed as expected (Firebug tells me so)
  • The headers seem alright (As seen in Firebug)

My problem is:

  • The file contents are never presented to me as a file that can be downloaded.

My suspicion was that the taqconite plugin somehow removes the headers. Even so, I'm not sure of the best way to solve it.

Any ideas would be most helpful.

Thanks /ft

+1  A: 

Until I can figure this one out, I'm just going with a direct link to download the file. (i.e No xmlhttp) to avoid the Jquery httpdata route.

A: 

Where is the file going then, if it's being streamed?

Sneakyness
I can see the file's contents in the firebug console, which tells me that the file is being streamed to the browser.