<div dir="ltr"><div><div>Hi again,<br><br></div>I can answer my own question: the code is fine and works properly. I was trying to access one of my test uploads from before I got the uploader working properly, without realising it. A new uploaded file downloads fine. The lack of log information appears to be due to EPrints doing some local caching of the data - is there any way to turn that off?<br>
<br></div>Simon<br></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Tue, Feb 5, 2013 at 12:54 PM, Simon McLeish <span dir="ltr">&lt;<a href="mailto:simon.mcleish@gmail.com" target="_blank">simon.mcleish@gmail.com</a>&gt;</span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="HOEnZb"><div class="h5"><div dir="ltr"><div><div><div><div><div><div><div><div>Hi,<br><br></div>I&#39;m trying to set up a custom storage module which communicates with a REST interface using LWP. I can store objects OK, and retrieve them directly (i.e. not through eprints). But when I try to retrieve an object through the EPrints interface I get the following in the log:<br>

<br>------------------------------------------------------------------<br>---------------- EPrints System Error ----------------------------<br>------------------------------------------------------------------<br>Error in file retrieval: failed to get file contents<br>

------------------------------------------------------------------<br> at /usr/share/eprints3/perl_lib/EPrints/Apache/Storage.pm line 261<br>    EPrints::Apache::Storage::handler(&#39;Apache2::RequestRec=SCALAR(0x7f9a1fb053c0)&#39;) called at -e line 0<br>

    eval {...} called at -e line 0<br>[Tue Feb 05 12:35:20 2013] [error] [client 138.38.192.151] EPrints::abort()\n, referer: <a href="https://float.bath.ac.uk/cgi/users/home?screen=EPrint::Edit&amp;eprintid=1&amp;stage=files" target="_blank">https://float.bath.ac.uk/cgi/users/home?screen=EPrint::Edit&amp;eprintid=1&amp;stage=files</a><br>

<br></div>The retrieve sub in the module looks like this:<br><br>sub retrieve<br>{<br>    my( $self, $fileobj, $sourceid, $offset, $n, $f ) = @_;<br><br>    my $repository = $self-&gt;{session}-&gt;get_repository;<br>    $repository-&gt;log( &quot;Attempting to set up user agent&quot; ) if ($self-&gt;{debug}); # for testing<br>

    if (create_ua( $self, $fileobj))<br>    {<br>        $repository-&gt;log( &quot;Attempting to access HCP &quot; . $self-&gt;{_url}-&gt;{$fileobj} ) if ($self-&gt;{debug}); # for testing<br>        my $ua = $self-&gt;{_ua}-&gt;{$fileobj};<br>

        my $request = new HTTP::Request(&#39;GET&#39;,$self-&gt;{_url}-&gt;{$fileobj});    <br>        my $response = $ua-&gt;request( $request,$f ); # feed the response to the callback function<br>        $repository-&gt;log( &quot;Have response&quot; ) if ($self-&gt;{debug}); # for testing<br>

        if( $response-&gt;is_error )<br>        {<br>            $repository-&gt;log( $response-&gt;as_string );<br>        }<br>        return $response-&gt;is_success;<br>    }<br>    else<br>    {<br>        $repository-&gt;log(&quot;Could not define LWP user agent: aborting file save\n&quot;);<br>

        return 0;<br>    }<br>}<br><br></div>The log doesn&#39;t seem to be receiving the debug info, either (which works fine in the open_write, write, and close_write subs). create_ua sets up the LWP object with the cookies needed for authentication, and saves it as $self-&gt;{_ua}-&gt;{$fileobj} - again, this works perfectly in the write routines.  According to the LWP docs, <br>

<br>$ua-&gt;request( $request,$f )<br><br></div>should feed back the content from the response to the callback function (&quot;this function will be called for each chunk of the response content as it is received from the server&quot; - <a href="http://search.cpan.org/~gaas/libwww-perl-6.04/lib/LWP/UserAgent.pm" target="_blank">http://search.cpan.org/~gaas/libwww-perl-6.04/lib/LWP/UserAgent.pm</a>).<br>

<br></div>I&#39;ve based the list of arguments to the sub on those in Local.pm - is is much of the rest of the EPrints interacting part of the code. This list is different from both the list at <a href="http://wiki.eprints.org/w/API:EPrints/Storage" target="_blank">http://wiki.eprints.org/w/API:EPrints/Storage</a> ($self, $fileobj, $offset, $n, CALLBACK ) and <a href="http://trac.eprints.org/eprints/browser/trunk/system/perl_lib/EPrints/Plugin/Storage/AmazonS3.pm?rev=4327" target="_blank">http://trac.eprints.org/eprints/browser/trunk/system/perl_lib/EPrints/Plugin/Storage/AmazonS3.pm?rev=4327</a> (the Amazon S3 module) ($self, $fileobj, $uri, $f) - could you possibly indicate which list is correct, if this isn&#39;t?<br>

<br></div>Any suggestions would be very welcome!<br><br></div>Thanks,<br></div>Simon<br></div>
</div></div><br>*** Options: <a href="http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech" target="_blank">http://mailman.ecs.soton.ac.uk/mailman/listinfo/eprints-tech</a><br>
*** Archive: <a href="http://www.eprints.org/tech.php/" target="_blank">http://www.eprints.org/tech.php/</a><br>
*** EPrints community wiki: <a href="http://wiki.eprints.org/" target="_blank">http://wiki.eprints.org/</a><br>
<br></blockquote></div><br></div>