[Bio] / FigWebServices / cluster_stage.cgi Repository:
ViewVC logotype

Annotation of /FigWebServices/cluster_stage.cgi

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (view) (download)

1 : olson 1.1 use strict;
2 :    
3 :     #use Common::Errors;
4 :    
5 :     =head1 Cluster Staging Interface
6 :    
7 :     This module provides a CGI interface for retrieving staged input files via HTTP.
8 :    
9 :     The client must provide the job id and work id for the staging work that we
10 :     are retrieving.
11 :    
12 :     =cut
13 :    
14 :     use strict;
15 :     use FIG;
16 :     use CGI;
17 :    
18 :     use Cluster;
19 :    
20 :     my $cgi = new CGI;
21 :    
22 :     sub fail($)
23 :     {
24 :     my($mesg) = @_;
25 :    
26 :     print $cgi->header(-type => "text/html",
27 :     -status => "500 error");
28 :     print "Staging failed: $mesg\n";
29 :     exit;
30 :     }
31 :    
32 :    
33 :     my $fig = new FIG;
34 :     my $job_id = $cgi->param("job_id");
35 :     my $work_id = $cgi->param("work_id");
36 :    
37 :     $job_id =~ /^\d+/ or fail "Invalid job_id\n";
38 :     $work_id =~ /^\d+/ or fail "Invalid work_id\n";
39 :    
40 :     my $c = new Cluster::Broker($fig);
41 :    
42 :     my ($fh, $size, $basename);
43 :    
44 :     my $ok = eval {
45 :     ($fh, $size, $basename) = $c->open_staging_file($job_id, $work_id);
46 :     };
47 :    
48 :     $ok or fail "$@";
49 :     $fh or fail "Cannot find staging file";
50 :    
51 :     print $cgi->header(-type => "application/octet-stream",
52 :     -Content_Length => $size,
53 :     -Content_Disposition => "attachment;filename=\"$basename\"",
54 :     );
55 :    
56 :     my $buf;
57 :     while (my $n = read($fh, $buf, 4096))
58 :     {
59 :     print $buf;
60 :     }
61 :    
62 :     close($fh);
63 :    
64 :    

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3