EPrints Technical Mailing List Archive

See the EPrints wiki for instructions on how to join this mailing list and related information.

Message: #01157


< Previous (by date) | Next (by date) > | < Previous (in thread) | Next (in thread) > | Messages - Most Recent First | Threads - Most Recent First

[EP-tech] Re: SWORD Endpoint


Ian,

I now have the depositing working as expected. Thanks very much for your help, it was greatly appreciated!

Thanks again,

Harry newton


On 9 Oct 2012, at 15:49, Ian Stuart <Ian.Stuart@ed.ac.uk> wrote:

> On 09/10/12 15:12, Harry Newton wrote:
>> Hi,
>> 
>> I have a question about depositing into ePrints via SWORD.
>> 
>> I have a php library to get the service document, then attempt to deposit a file. However, the service document always returns 401 unauthorised. This is even though I'm passing the username and password.
>> As for depositing, I am unsure of the url I should be depositing to. I understand it is my ePrints host, but what would the rest of the URL be? For example, the service document is <eprints>/sword-app/servicedocument. I just need to know how to deposit for a specific ePrint of a specific user.
> 
> You want some code something like:
> 
> my $username = "user1"; # to be defined
> my $password = "topSecret"; # to be defined
> my $host     = "my.server.example.com";
> my $endpoint = "sword-app/deposit";
> my $collection = "archive"; # could be "review" or "inbox"
> my $url = "http://"; . $username . ":" . $password . "@"
>                     . $host . "/" . $endpoint . "/" . $collection;
> 
> my $archive = read_file("$dirname/$zipfile", binmode => ':raw' ) or 
> die('cant open input file');
>   my $ua = LWP::UserAgent->new();
>   my $req = HTTP::Request->new( POST => '' );
>   $req->header( 'X-Packaging' => 'known_format',
>                 'X-No-Op' => 'false',
>                 'X-Verbose' => 'false',
>                 'Content-Disposition' => "filename=$zipfile"
>   );
>   $req->content_type( 'application/zip' );
>   $req->content( $archive );
>   my $res = $ua->request($req);	
>   if ($res->is_success) {
>         print "$zipfile deposited.\n";
>         $count++;
>   }
>   else { print "$zipfile - ".$res->status_line, "\n"; }
> }
> 
> The challenge is knowing the string for "known_format" (and the 
> servicedocument will tell you what the server will accept), and making 
> the right metadata file in the .zip file.
> 
> -- 
> 
> Ian Stuart.
> Developer: ORI, RJ-Broker, and OpenDepot.org
> Bibliographics and Multimedia Service Delivery team,
> EDINA,
> The University of Edinburgh.
> 
> http://edina.ac.uk/
> 
> This email was sent via the University of Edinburgh.
> 
> The University of Edinburgh is a charitable body, registered in
> Scotland, with registration number SC005336.
> 
> *** Options: http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech
> *** Archive: http://www.eprints.org/tech.php/
> *** EPrints community wiki: http://wiki.eprints.org/