[Bio] / Clearinghouse / pkg_download.pl Repository:
ViewVC logotype

View of /Clearinghouse/pkg_download.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.4 - (download) (as text) (annotate)
Thu Apr 28 21:43:48 2005 UTC (14 years, 5 months ago) by olson
Branch: MAIN
CVS Tags: myrast_33, HEAD
Changes since 1.3: +19 -1 lines
add text download option.

use strict;
use Data::Dumper;
use FIG;
use FIG_Config;
use CGI qw/:standard :html3/;
use Clearinghouse::ch_database;


#id is id in package_location
my $id = param('ID');

#
# If view is true, mark it as a text download.
#

my($type, $name);

if (param('view'))
{
    $type = "text/plain";
    $name = "download_$id.txt";
}
else
{
    $type = "application/x-download";
    $name = "download.$id";
}

#get the path name from the database
my $db = db_init();

my $res = $db->SQL(q{SELECT pathname from  package_location  where id = ?}, undef, $id);
my $path = $res->[0]->[0];

print header(-type => $type,
	     -attachment => $name);

my $buf;
open(my $myout, "<$path");
while (read($myout, $buf, 4096))
{	
print $buf;
}
close($myout);


MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3