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

View of /Clearinghouse/test_let_me_give_you_this.pl

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.6 - (download) (as text) (annotate)
Wed Apr 20 19:54:31 2005 UTC (14 years, 5 months ago) by olson
Branch: MAIN
CVS Tags: myrast_33, HEAD
Changes since 1.5: +4 -2 lines
Replace hardcoded service url with $CH_Config::service_url.

Unset HTTP_HOST in the service so that FIG::cgi_url  works.

#!/usr/bin/env perl

use SOAP::Lite;
use LWP::UserAgent;
use HTTP::Request::Common;

use CH_Config;

if (@ARGV < 6) {
        die "Usage let_me_give_you_this type, who, meta_data, description, source, path(s)...\n";
}
	my $type = shift;
	my $who = shift;
	my $meta_data = shift;
	my $description = shift;
	my $source = shift;
	my @path = @ARGV;


my $data = `cat $meta_data`;

my $proxy = SOAP::Lite-> uri('http://www.soaplite.com/Scripts')
	-> proxy($CH_Config::service_url);

#step 1 - get url to upload to
#
my @id_list;
for my $path (@path) {
	$response = $proxy->get_upload_url();  

	if ($response->fault)
	    {
		die "Failed to deposit: ", $response->faultcode, " ", $response->faultstring, "\n";
	    }

	my ($url, $id) = @{$response->result};
	print $url, $id, "\n";
	push @id_list, $id;
	

	#
	#step 2 - upload the file (The url is pkg_upload.cgi)
	#
	# get the file size
	my $size = -s $path;

	$HTTP::Request::Common::DYNAMIC_FILE_UPLOAD = 1;

	#print "Uploading file $path to $url...\n";
	my $req = POST($url,
		   Content_Type => 'form-data',
		   Content => [file_id => $id,
			       file_size=> $size,
			       file => [$path]]);

#
#
	my $ua = new LWP::UserAgent;
	my $resp = $ua->request($req);
	if (!$resp->is_success) {
		die "Failed to upload $path";
	}
}

#step 3 - finish up, this makes the entry in the DB
# now finish the deposit
$response = $proxy->finish_upload(\@id_list, $type, $who, $data, $description, $source);  
#check this response sometime

MCS Webmaster
ViewVC Help
Powered by ViewVC 1.0.3