wolfie7873 has asked for the wisdom of the Perl Monks concerning the following question:
I would use Apache2, instead, but that's minor. What I can't figure out how to do is make this work using a BLOB object instead of a file on disk. One way would be to override the headers, but the Apache::request and Apache2::request objects are just different enough that I'm not sure how to proceed. Here is one long way around:use Apache::SubRequest; my $subr = $r->lookup_file($file); return 404 unless -f $file and $subr->status == 200; $r->content_type($subr->content_type); $r->send_http_header; return 200 if $r->header_only; $subr->run; $m->abort;
This gets me around the BLOB problem, but there's no $r->header_out method in Apache2, and I can't figure out the correct structure use of Apache2::headers_out() from the documentation. I'm sure it's something obvious, but I'm stumped.$r->content_type('application/octet-stream'); $r->header_out('Content-disposition' => ("attachment; filename=$filen +ame_base")); open($fh,"<".$filename_full) or $m->redirect('file_open_failed.html?na +me='.$filename_full); while(<$fh>) { $m->print($_); } close $fh; return;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File download from BLOB
by bluescreen (Friar) on Mar 25, 2011 at 15:46 UTC | |
by wolfie7873 (Novice) on Mar 25, 2011 at 15:57 UTC | |
by Eliya (Vicar) on Mar 25, 2011 at 19:33 UTC | |
|
Re: File download from BLOB
by locked_user sundialsvc4 (Abbot) on Mar 25, 2011 at 16:46 UTC | |
by wolfie7873 (Novice) on Mar 25, 2011 at 20:00 UTC | |
by Eliya (Vicar) on Mar 25, 2011 at 21:34 UTC | |
|
Re: File download from BLOB
by Anonymous Monk on Mar 28, 2011 at 03:34 UTC | |
by wolfie7873 (Novice) on Mar 28, 2011 at 13:54 UTC | |
by wolfie7873 (Novice) on Mar 28, 2011 at 14:27 UTC |