<html><head>
<meta name="Generator" content="Novell Groupwise Client (Version 14.0.1 Build: 117118)">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"></head>
<body style="font: 10pt/normal Segoe UI; margin: 16px 16px 4px; font-size-adjust: none; font-stretch: normal;"><div class="GroupWiseMessageBody" id="GroupWiseSection_1442936723000_Andy.Reid@lshtm.ac.uk_E7E91160180E0000BAA6000000100002_"><div>On reflection, that may be more confusing than I first thought - I should have explained that I had to deal with manuscripts where there were several files per document - Main body, cover page, tables, figures, etc - and the file metadata was already in a database. If you are just working from one file per eprint, then you don't need the loop for building up the series of files, obviously. But I thought the XML templates might be useful. </div><div><br></div><div>Andy<br></div><div class="GroupWiseMessageBody" id="GroupWiseSection_1442934304000_Andy.Reid@lshtm.ac.uk_E7E91160180E0000BAA6000000100002_"><span class="GroupwiseReplyHeader">>>> "Andy Reid" <Andy.Reid@lshtm.ac.uk> 22 September 2015 16:18 >>><br></span><div>Hi George,</div><div>Here's a chunk of PHP I put together recently to generate the documents/files section of an Eprints XML upload. This puts all the files into one document tag, which may or may not be waht you want to do - I'm not sure exactly how standard the mainfile configuration is on our system, but it seems to only allow the one file per document to be downloaded. So either you need to enclose each file in a separate document tag, or as I eventually did, zip all the files and push that up as one file. This version is the 'one document, many files' approach, but I can send you the Zip version as well if you like.</div><div><br></div><div><?php<br>function eprints_xml_OAfiles($row){ # $row is the metadata values for this record<br><br>global $link;<br>global $dataset;<br>$docroot=$_SERVER['DOCUMENT_ROOT'];<br>$filebase="$docroot/publications/administration/.... <where the files live > /";<br><br> <br>$pub_id = $row['pub_id'];<br>$oaPub_ID = $row['oaPub_ID']; <br><br> $PM= $row['pubmedid'] ; <br> </div><div><br></div><div><br></div><div><br> $files_query = "SELECT<br> oaPub_ID,<br> `oaManuscript_ID`,<br> `oaPub_ID`,<br> `content_oaManuscript`, # Manuscript<br> `file_oaManuscript`,<br> `file_oaManuscript_mimetype`,<br> `URL_oaManuscript`,<br> `upload_oaManuscript`,<br> `notes_oaManuscript`,<br> `modified_oaManuscript`<br> <br> FROM<br> oaManuscript2<br> WHERE<br> <br> oaPub_ID = $oaPub_ID<br> and upload_oaManuscript = 1<br> ";<br> # ORDER BY surname";<br> $files_result = mysql_query ($files_query,$link)<br> or die ("Query failed:$files_query");<br> <br> $filesXML=""; <br> while ($f = mysql_fetch_array($files_result)) { #build file metadata and base64 data<br> $record=print_r($f,TRUE); echo "<!-- $record -->";<br> $filename = $f['file_oaManuscript'];<br> $mimetype = $f['file_oaManuscript_mimetype'];<br> if(FALSE === ($STUFF=file_get_contents($filebase.$filename))){die("\n\nfailed to get file: $filebase$filename");}<br> $base64=chunk_split(base64_encode($STUFF));<br> $hash=md5($base64); <br> $filesize = strlen($STUFF);<br> $file_modified= $f['modified_oaManuscript'];<br> <br> <br> <br>$filesXML .= "<br> <br> <file><br> <br> <datasetid>document</datasetid><br> <br> <filename>$filename</filename><br> <mime_type>$mimetype</mime_type><br> <hash>$hash</hash><br> <hash_type>MD5</hash_type><br> <filesize>$filesize </filesize><br> <mtime>$file_modified</mtime><br> <br> <data encoding='base64'>";</div><div><br></div><div>$filesXML .= $base64;</div><div><br></div><div>#.=chunk_split(base64_encode(file_get_contents($fileURLbase.$filename)));<br>$filesXML .= "</data><br> </file>";</div><div><br></div><div><br></div><div><br></div><div> }# ends while ($row2 = mysql_fetch_array($coded_result)) <br> </div><div><br></div><div><br> </div><div><br></div><div><br></div><div><br></div><div>return $cit = <<<EOC<br><documents><br><document><br> <mime_type>$maintype</mime_type><br> <format>text</format><br> <language>en</language><br> <security>public</security><br> <license>cc_by</license><br> <main>$mainfile</main><br> <content>accepted</content><br> <br> <files><br> <br> $filesXML<br> </files><br> </document><br></documents></div><div><br></div><div><br>EOC;</div><div><br></div><div>}<br>?> <br></div></div><div class="GroupWiseMessageBody" id="GroupWiseSection_1442929240000_mamalos@eng.auth.gr"><span class="GroupwiseReplyHeader">>>> George Mamalakis <mamalos@eng.auth.gr> 22 September 2015 14:40 >>><br></span><div><div>Hi everybody!<br><br>I'm very close to finishing my EPrints configuration + migration from <br>DSpace. The main thing that remains to be done, is the data migration part.<br><br>I've written a python script that generates an EPrints XML file based on <br>a DSpace csv file, that I'll upload to EPrints Wiki when it'll be done.<br><br>In order to complete it, I need to add the file, and I am not aware as <br>to what syntax I should use. I have a local folder whose subfolders <br>contain all DSPace files, where each subfolder name is the record id. <br>Therefore, my folder structure is somewhat like this:<br><br>/home/data/dspace/{record_id}<br><br>where {record_id} is the DSpace id of the specific record. What are the <br>minimum XML attributes that have to be added in my XML file in order for <br>EPrints to import the files? And how would an example XML entry look <br>like based on our example folder structure?<br><br>Thanks all in advance!<br><br>-- <br>George Mamalakis<br><br>IT and Security Officer,<br>Electrical and Computer Engineer (Aristotle Univ. of Thessaloniki),<br>PhD (Aristotle Univ. of Thessaloniki),<br>MSc (Imperial College of London)<br><br>School of Electrical and Computer Engineering<br>Aristotle University of Thessaloniki<br><br>phone number : +30 (2310) 994379<br><br><br>*** Options: <a href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br>*** Archive: <a href="http://www.eprints.org/tech.php/">http://www.eprints.org/tech.php/</a><br>*** EPrints community wiki: <a href="http://wiki.eprints.org/">http://wiki.eprints.org/</a><br>*** EPrints developers Forum: <a href="http://forum.eprints.org/">http://forum.eprints.org/</a><br></div></div></div></div></body></html>