Hi all,

I am pretty new to this, but am just testing a SWORD service that has been 
created for our ArchivalWare-based repository.

I have been trying to use the PHP library to create a simple client to deposit 
files to the test library. I find that the packager (PackagerMetsSwap) seems to 
work fine, and I can deposit these using curl from the command line, but the 
SWORDAPPclient->deposit() function is broken.

The problem lies on line 98:

curl_setopt($sac_curl, CURLOPT_READDATA, fopen($sac_fname, 'rb'));

"CURLOPT_READDATA" appears to be part of libcurl, but not implemented in 
(current versions?) of PHP (it's not listed in the documentation for 
curl_setopt - http://uk2.php.net/manual/en/function.curl-setopt.php ).

I have been trying to use CURLOPT_POSTFIELDS to upload, but am getting repeated 
errors, including 415 (unsupported media type) return codes, and "Type 
application/zip; boundary=----------------------------52629833d905 is not 
accepted in collection 2ERROR<timestamp>"

CURLOPT_POSTFIELDS expects an associative array, with the filename so I'm 
thinking that this might be part of the problem, or it might be an issue with 
Content-Type (repository is expecting "application/zip", and this is what I 
have been stating on the command line, but I understand that curl posts 
"multipart/form-data").

Any advice would be welcome. The code I've been trying, with several 
variations, is:

   $dep_url = "http://username:passw...@repository.ac.uk/path/to/library";;
   $dep_file = $filename
   $dep_on_behalf = $copyright-holder;
   $dep_packaging = "http://www.loc.gov/METS/";;
   $dep_cont_type = "application/zip"; // I've tried "multipart/form-data" as 
well
   $dep_verbose = "true";
   $dep_noop = "false";

   $ch = curl_init($dep_url);
   $headers = array("X-Packaging: $dep_packaging",
      "Content-Type: $dep_cont_type","X-No-Op: $dep_noop",
      "Content-Disposition: filename=$dep_file",
      "X-Verbose: $dep_verbose");
   curl_setopt($ch,CURLOPT_HTTPHEADER, $headers);
   curl_setopt($ch,CURLOPT_POST,1);
   $data = array('filename' => '@file/path/'.$dep_file);
   curl_setopt($ch,CURLOPT_POSTFIELDS,$data);
   curl_exec($ch);
   curl_close($ch);
   chdir($cdir);

Rob Hardy
Digital Archive, Web and System Support Librarian
York St John University Library and Information Services
Lord Mayor's Walk, YORK, YO31 7EX
01904 876701
http://library.yorksj.ac.uk<http://library.yorksj.ac.uk/>
r.ha...@yorksj.ac.uk<mailto:r.ha...@yorksj.ac.uk>

------------------------------------------------------------------------------
10 Tips for Better Web Security
Learn 10 ways to better secure your business today. Topics covered include:
Web security, SSL, hacker attacks & Denial of Service (DoS), private keys,
security Microsoft Exchange, secure Instant Messaging, and much more.
http://www.accelacomm.com/jaw/sfnl/114/51426210/
_______________________________________________
sword-app-tech mailing list
sword-app-tech@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/sword-app-tech

Reply via email to