Difference between revisions of "API:EPrints/Storage"
Line 9: | Line 9: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 24: | Line 24: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 33: | Line 33: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 40: | Line 40: | ||
==METHODS== | ==METHODS== | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 50: | Line 50: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 62: | Line 62: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 70: | Line 70: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 80: | Line 80: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 90: | Line 90: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 104: | Line 104: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 116: | Line 116: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 126: | Line 126: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 138: | Line 138: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 148: | Line 148: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 158: | Line 158: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
Line 168: | Line 168: | ||
<div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | <div style='background-color: #e8e8f; margin: 0.5em 0em 1em 0em; border: solid 1px #cce; padding: 0em 1em 0em 1em; font-size: 80%; '> | ||
− | + | <span style='display:none'>User Comments</span> | |
<!-- Edit below this comment --> | <!-- Edit below this comment --> | ||
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment --> | <!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment --> |
Revision as of 11:55, 25 February 2010
EPrints 3 Reference: Directory Structure - Metadata Fields - Repository Configuration - XML Config Files - XML Export Format - EPrints data structure - Core API - Data Objects
Latest Source Code (3.4, 3.3) | Revision Log | Before editing this page please read Pod2Wiki
Contents
- 1 NAME
- 2 SYNOPSIS
- 3 DESCRIPTION
- 4 METHODS
- 4.1 $store = EPrints::Storage->new( $repository )
- 4.2 $len = $store->store( $fileobj, CODEREF )
- 4.3 $success = $store->retrieve( $fileobj, CALLBACK )
- 4.4 $success = $store->delete( $fileobj )
- 4.5 $ok = $store->delete_copy( $plugin, $fileobj )
- 4.6 $filename = $store->get_local_copy( $fileobj )
- 4.7 $url = $store->get_remote_copy( $fileobj )
- 4.8 @plugins = $store->get_plugins( $fileobj )
- 4.9 $ok = $store->copy( $plugin, $fileobj )
- 4.10 $ok = $storage->open_write( $fileobj )
- 4.11 $ok = $storage->write( $fileobj, $buffer )
- 4.12 $ok = $storage->close_write( $fileobj );
NAME
EPrints::Storage - store and retrieve objects in the storage engine
SYNOPSIS
my $store = $repository->storage(); $store->store( $fileobj, # file object "diddle.pdf", # filename $fh # file handle );
DESCRIPTION
This module is the storage control layer which uses EPrints::Plugin::Storage plugins to support various storage back-ends. It enables the storage, retrieval and deletion of data streams. The maximum size of a stream is dependent on the back-end storage mechanism.
METHODS
$store = EPrints::Storage->new( $repository )
Create a new storage object for $repository. Should not be used directly, see EPrints::Session.
$len = $store->store( $fileobj, CODEREF )
Read from and store all data from CODEREF for $fileobj. The filesize field in $fileobj must be set at the expected number of bytes to read from CODEREF.
Returns undef if the file couldn't be stored, otherwise the number of bytes read.
$success = $store->retrieve( $fileobj, CALLBACK )
$success = $store->delete( $fileobj )
Delete all object copies stored for $fileobj.
$ok = $store->delete_copy( $plugin, $fileobj )
Delete the copy of this file stored in $plugin.
$filename = $store->get_local_copy( $fileobj )
Return the name of a local copy of the file.
Will retrieve and cache the remote object using File::Temp if necessary.
Returns undef if retrieval failed.
$url = $store->get_remote_copy( $fileobj )
Returns a URL from which this file can be accessed.
Returns undef if this file is not available via another service.
@plugins = $store->get_plugins( $fileobj )
Returns the EPrints::Plugin::Storage plugin(s) to use for $fileobj. If more than one plugin is returned they should be used in turn until one succeeds.
$ok = $store->copy( $plugin, $fileobj )
Copy the contents of $fileobj into another storage $plugin.
Returns 1 on success, 0 on failure and -1 if a copy already exists in $plugin.
$ok = $storage->open_write( $fileobj )
Start a write session for $fileobj. $fileobj must have at least the "filesize" property set (which is the number of bytes that will be written).
$ok = $storage->write( $fileobj, $buffer )
Write $buffer to the storage plugin(s).
$ok = $storage->close_write( $fileobj );
Finish writing to the storage plugin(s) for $fileobj.