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

Annotation of /Clearinghouse/pkg_upload.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (view) (download) (as text)

1 : disz 1.1 use strict;
2 :     use Data::Dumper;
3 :     use FIG;
4 : olson 1.5 use CH_Config;
5 : disz 1.1 use FIG_Config;
6 :     use CGI;
7 : olson 1.6 use Clearinghouse::ch_database;
8 :    
9 : disz 1.4 use File::Temp qw/ :mktemp /;
10 : disz 1.1
11 :     my $c = new CGI();
12 :    
13 :     my $id = $c->param('file_id');
14 : disz 1.3 my $size = $c->param('file_size');
15 : disz 1.1 my $file = $c->param('file');
16 :    
17 : disz 1.4 my $path = mktemp("$CH_Config::dir/clgXXXX");
18 : disz 1.1 open(LOCAL, ">$path") or die $!;
19 :     while(<$file>) {
20 :     print LOCAL $_;
21 :     }
22 : disz 1.3
23 :     close(LOCAL);
24 :    
25 : disz 1.1 #test for successful upload
26 :     if (! -f $path) {
27 : disz 1.3 print $c->header(-status => '500 upload failed');
28 :     exit;
29 :     }
30 :    
31 :     if ($size != -s $path) {
32 :     print $c->header(-status => '500 upload incomplete');
33 :     exit;
34 : disz 1.1 }
35 : disz 1.3
36 : disz 1.1 #now update name into the db
37 :    
38 : olson 1.6 my $db = db_init();
39 : disz 1.3
40 : disz 1.4 my $res = $db->SQL(q{UPDATE package_location SET pathname = ? where id = ?}, undef, $path, $id);
41 : disz 1.1
42 : disz 1.3 if (!$res) {
43 :     print $c->header("500 DB Update error".$db->{_dbh}->errstr);
44 :     exit;
45 :     }
46 : disz 1.1
47 : disz 1.3 print $c->header();
48 : disz 1.1 print "Successful upload\n"

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3