Posted by: Ian | October 12, 2010

Multi-deposit, a reality

After a few days on head-banging and follicle scratching (not that I have much hair left these days), I have a proof-of-concept for multiple deposit.

One script, one package, and transfer the same package to multiple repositories!

I need to know the following things:

  • The host (eg OpenDepot.org)
  • The URL for the collection (eg ‘/sword/deposit/123456789/2’)
  • The user name to deposit as, encoded (such as name%40some.domain)
  • The password for that user name (in plain text: myUselessPassword)

I have tested this with OpenDepot, JorumOpen, and ShareGeoOpen

The basic Perl code is pretty easy too:

$ua = LWP::UserAgent->new();
$req = HTTP::Request->new( POST => 'http://'.$username.":".$password."@".$host.$collection );
$req->header( 'X-Packaging' => 'http://purl.org/net/sword-types/METSDSpaceSIP',
 'X-No-Op' => 'false',
 'X-Verbose' => 'false',
 'Content-Disposition' => "filename=$filename"
 );
$req->content_type( 'application/zip' );
$req->content( $file_contents );
$res = $ua->request($req);
print $res->is_success ? "Deposit successful.\n" : $res->status_line, "\n"

 

…. stick in an appropriate loop, and you have multiple depositing.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: