Perl CGI::Application::Plugin:Stream + Jquery Taconite plugin - Cannot download file

600 views Asked by At

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

2

There are 2 answers

0
user135667 On

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.

1
Sneakyness On

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