source: main/trunk/greenstone2/cgi-bin/talkback-transfer.pl@ 23091

Last change on this file since 23091 was 23091, checked in by davidb, 14 years ago

CGI Script that runs on local DL server, but effects the transfer of the specified document to the specified external Greenstone server

  • Property svn:executable set to *
File size: 1.5 KB
Line 
1#/usr/bin/perl -w
2
3use strict;
4
5use LWP::UserAgent;
6use HTTP::Request::Common;
7
8use CGI::Carp qw(fatalsToBrowser);
9use CGI;
10
11eval('require "./gsdlCGI.pm"');
12if ($@)
13{
14 print STDOUT "Content-type:text/plain\n\n";
15 print STDOUT "ERROR: $@\n";
16 exit 0;
17}
18
19
20sub main
21{
22 # Setup greenstone Perl include paths so additional packages can be found
23 my $gsdl_cgi = gsdlCGI->new();
24 $gsdl_cgi->setup_gsdl();
25
26 require talkback;
27
28 my $rand_string;
29 if (defined $gsdl_cgi->param('rand_string')) {
30 $rand_string = $gsdl_cgi->param('rand_string');
31 }
32 else {
33 $rand_string = "b310f690273cdc025e5a9b49fca8eee8";
34 }
35
36 my $uploadedfile;
37 if (defined $gsdl_cgi->param('uploadedfile')) {
38 $uploadedfile = $gsdl_cgi->param('uploadedfile');
39 }
40 else {
41 $uploadedfile = "C:\\cygwin\\tmp\\test-medium.pdf";
42 }
43
44 my $talktoUploadURL;
45 if (defined $gsdl_cgi->param('talkbackUpload')) {
46 $talktoUploadURL = $gsdl_cgi->param('talktoUpload');
47 }
48 else {
49 $talktoUploadURL = "http://www.nzdl.org/gsdl-new/cgi-bin/talkback-progressbar.pl";
50 }
51
52 my $browser = LWP::UserAgent->new(agent => 'Perl File Upload');
53
54 my $response = $browser->post(
55 $talktoUploadURL,
56 [ 'yes_upload' => '1',
57 'process' => '1',
58 'rand_string' => $rand_string,
59 'uploadedfile' => [$uploadedfile, "test-medium.pdf"]
60 ],
61 'Content_Type' => 'form-data'
62 );
63
64 if ($response->is_success) {
65 print "Content-type:text/html\n\n";
66 print $response->content;
67 }
68 else {
69 print $response->error_as_HTML;
70 }
71
72}
73
74main();
75
Note: See TracBrowser for help on using the repository browser.