API:EPrints/Plugin/Storage

From EPrints Documentation
Revision as of 13:47, 25 July 2013 by Tdb01r (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to: navigation, search

EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects


API: Core API

Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki


NAME

EPrints::Plugin::Storage


SYNOPSIS

$plugin = $repo->plugin('Storage::Local');
$plugin->open_write($fileobj) or die;
$plugin->write('Hello, World!');
$plugin->close_write() or die;


DESCRIPTION

See EPrints::Storage for information on using the storage layer.

You shouldn't need to use a storage plugin directly.


METHODS

store

$sourceid = $store->store( $fileobj, CALLBACK )

Store an object using data from CALLBACK.

If successful returns the source id used to retrieve this object.

Returns undef on error.


retrieve

$success = $store->retrieve( $fileobj, $sourceid, $offset, $len, CALLBACK )

Retrieve $n bytes of data starting at $offset from the data stored for $fileobj identified by $sourceid.

CALLBACK = $rc = &f( BYTES )

Note: this API may change in future to reflect the open_write/write/close_write mechanism.


delete

$success = $store->delete( $fileobj, $sourceid )

Delete the object stored for $fileobj.


get_local_copy

$filename = $store->get_local_copy( $fileobj, $sourceid )

Return the name of a local copy of the file (may be a File::Temp object).

Returns undef if no local copy is available.


get_remote_copy

$url = $store->get_remote_copy( $fileobj, $sourceid )

Returns an alternative URL for this file (must be publicly accessible).

Returns undef if no such copy is available.


open_write

$ok = $store->open_write( $fileobj )

Initialise a new write based on $fileobj.


write

$ok = $store->write( $fileobj, $buffer )

Write $buffer. Will croak if $fileobj was not previously opened for writing with open_write().


close_write

$sourceid = $store->close_write( $fileobj )

Finish writing to $fileobj. Returns the sourceid or undef on failure.


COPYRIGHT

Copyright 2000-2011 University of Southampton.

This file is part of EPrints http://www.eprints.org/.

EPrints is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.

EPrints is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public License along with EPrints. If not, see http://www.gnu.org/licenses/.