Difference between revisions of "API:EPrints/DataObj/File"

From EPrints Documentation
Jump to: navigation, search
(New page: not done yet.)
 
Line 1: Line 1:
not done yet.
+
<!-- Pod2Wiki=_preamble_
 +
This page has been automatically generated from the EPrints 3.2 source. Any wiki changes made between the 'Pod2Wiki=*' and 'Edit below this comment' comments will be lost.
 +
-->{{API}}{{Pod2Wiki}}{{API:Source|file=EPrints/DataObj/File.pm|package_name=EPrints::DataObj::File}}[[Category:API|File]]<div><!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki=_private_ --><!-- Pod2Wiki=head_name -->
 +
==NAME==
 +
'''EPrints::DataObj::File''' - a stored file
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_description -->
 +
==DESCRIPTION==
 +
This class contains the technical metadata associated with a file. A file is a sequence of bytes stored in the storage layer (a "stored object"). Utility methods for storing and retrieving the stored object from the storage layer are made available.
 +
 
 +
Revision numbers on File work slightly differently to other objects. A File is only revised when it's stored object is changed and not when changes to it's metadata are made.
 +
 
 +
This class is a subclass of [[API:EPrints/DataObj/SubObject|EPrints::DataObj::SubObject]].
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_core_fields -->
 +
==CORE FIELDS==
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_fileid -->
 +
===fileid===
 +
 
 +
Unique identifier for this file.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_rev_number -->
 +
===rev_number (int)===
 +
 
 +
The number of the current revision of this file.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_datasetid -->
 +
===datasetid===
 +
 
 +
Id of the dataset of the parent object.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_objectid -->
 +
===objectid===
 +
 
 +
Id of the parent object.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_filename -->
 +
===filename===
 +
 
 +
Name of the file (may contain directory separators).
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_mime_type -->
 +
===mime_type===
 +
 
 +
MIME type of the file (e.g. "image/png").
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_hash -->
 +
===hash===
 +
 
 +
Check sum of the file.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_hash_type -->
 +
===hash_type===
 +
 
 +
Name of check sum algorithm used (e.g. "MD5").
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_filesize -->
 +
===filesize===
 +
 
 +
Size of the file in bytes.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_mtime -->
 +
===mtime===
 +
 
 +
Last modification time of the file.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_url -->
 +
===url===
 +
 
 +
Virtual field for storing the file's URL.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_data -->
 +
===data===
 +
 
 +
Virtual field for storing the file's content.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_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%; '>
 +
<span style='display:none'>User Comments</span>
 +
<!-- Edit below this comment -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_constructor_methods -->
 +
===Constructor Methods===
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_new_from_filename -->
 +
====new_from_filename====
 +
 
 +
$dataobj = EPrints::DataObj::File-&gt;new_from_filename( $session, $dataobj, $filename )
 +
Convenience method to get an existing File object for $filename stored in $dataobj.
 +
 
 +
Returns undef if no such record exists.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_create_from_data -->
 +
====create_from_data====
 +
 
 +
$dataobj = EPrints::DataObj::File-&gt;create_from_data( $session, $data [, $dataset ] )
 +
Create a new File record using $data. If "_content" is defined in $data it will be read from and stored - for possible values see set_file().
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_class_methods -->
 +
===Class Methods===
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_get_system_field_info -->
 +
====get_system_field_info====
 +
 
 +
$thing = EPrints::DataObj::File-&gt;get_system_field_info
 +
Core fields.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_get_dataset_id -->
 +
====get_dataset_id====
 +
 
 +
$dataset = EPrints::DataObj::File-&gt;get_dataset_id
 +
Returns the id of the [[API:EPrints/DataSet|EPrints::DataSet]] object to which this record belongs.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_get_defaults -->
 +
====get_defaults====
 +
 
 +
$defaults = EPrints::DataObj::File-&gt;get_defaults( $session, $data )
 +
Return default values for this object based on the starting data.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_object_methods -->
 +
===Object Methods===
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_clone -->
 +
====clone====
 +
 
 +
$new_file = $file-&gt;clone( $parent )
 +
Clone the $file object (including contained files) and return the new object.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_remove -->
 +
====remove====
 +
 
 +
$success = $file-&gt;remove
 +
Delete the stored file.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_get_local_copy -->
 +
====get_local_copy====
 +
 
 +
$filename = $file-&gt;get_local_copy()
 +
Return the name of a local copy of the file (may be a {{API:PodLink|file=File/Temp|package_name=File::Temp|section=|text=File::Temp}} object).
 +
 
 +
Will retrieve and cache the remote object if necessary.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_add_file -->
 +
====add_file====
 +
 
 +
$success = $file-&gt;add_file( $filepath, $filename [, $preserve_path ] )
 +
Read and store the contents of $filepath at $filename.
 +
 
 +
If $preserve_path is untrue will strip any leading path in $filename.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_upload -->
 +
====upload====
 +
 
 +
$bytes = $file-&gt;upload( $filehandle, $filename, $filesize [, $preserve_path ] )
 +
Read and store the data from $filehandle at $filename at the next revision number.
 +
 
 +
If $preserve_path is untrue will strip any leading path in $filename.
 +
 
 +
Returns the number of bytes read from $filehandle or undef on failure.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_write_copy -->
 +
====write_copy====
 +
 
 +
$success = $stored-&gt;write_copy( $filename )
 +
Write a copy of this file to $filename.
 +
 
 +
Returns true if the written file contains the same number of bytes as the stored file.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_write_copy_fh -->
 +
====write_copy_fh====
 +
 
 +
$success = $stored-&gt;write_copy_fh( $filehandle )
 +
Write a copy of this file to $filehandle.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_generate_md5 -->
 +
====generate_md5====
 +
 
 +
$md5 = $stored-&gt;generate_md5
 +
Calculates and returns the MD5 for this file.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_generate_sha -->
 +
====generate_sha====
 +
 
 +
$digest = $file-&gt;generate_sha( [ ALGORITHM ] )
 +
Generate a SHA for this file, see {{API:PodLink|file=Digest/SHA/PurePerl|package_name=Digest::SHA::PurePerl|section=|text=Digest::SHA::PurePerl}} for a list of supported algorithms. Defaults to "256" (SHA-256).
 +
 
 +
Returns the hex-encoded digest.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_add_plugin_copy -->
 +
====add_plugin_copy====
 +
 
 +
$stored-&gt;add_plugin_copy( $plugin, $sourceid )
 +
Add a copy of this file stored using $plugin identified by $sourceid.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_remove_plugin_copy -->
 +
====remove_plugin_copy====
 +
 
 +
$stored-&gt;remove_plugin_copy( $plugin )
 +
Remove the copy of this file stored using $plugin.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_get_file -->
 +
====get_file====
 +
 
 +
$success = $stored-&gt;get_file( CALLBACK )
 +
Get the contents of the stored file - see [[API:EPrints/Storage|EPrints::Storage]]::retrieve().
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=item_set_file -->
 +
====set_file====
 +
 
 +
$content_length = $stored-&gt;set_file( CONTENT, $content_length )
 +
Reads data from CONTENT and stores it. Sets the MD5 hash and filesize.
 +
 
 +
If the write failed returns undef and sets the filesize to 0.
 +
 
 +
CONTENT may be one of:
 +
 
 +
  CODEREF - will be called until it returns empty string ("")
 +
  SCALARREF - a scalar reference will be used as-is (expects bytes)
 +
  GLOB - will be treated as a file handle and read with sysread()
 +
 
 +
This method does not check the actual number of bytes read is the same as $content_length.
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=head_see_also -->
 +
==SEE ALSO==
 +
[[API:EPrints/DataObj|EPrints::DataObj]] and [[API:EPrints/DataSet|EPrints::DataSet]].
 +
 
 +
<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 -->
 +
 
 +
 
 +
<!-- Pod2Wiki= -->
 +
</div>
 +
<!-- Pod2Wiki=_postamble_ --><!-- Edit below this comment -->

Revision as of 13:21, 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


API: Core API

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


NAME

EPrints::DataObj::File - a stored file

User Comments


DESCRIPTION

This class contains the technical metadata associated with a file. A file is a sequence of bytes stored in the storage layer (a "stored object"). Utility methods for storing and retrieving the stored object from the storage layer are made available.

Revision numbers on File work slightly differently to other objects. A File is only revised when it's stored object is changed and not when changes to it's metadata are made.

This class is a subclass of EPrints::DataObj::SubObject.

User Comments


CORE FIELDS

User Comments


fileid

Unique identifier for this file.

User Comments


rev_number (int)

The number of the current revision of this file.

User Comments


datasetid

Id of the dataset of the parent object.

User Comments


objectid

Id of the parent object.

User Comments


filename

Name of the file (may contain directory separators).

User Comments


mime_type

MIME type of the file (e.g. "image/png").

User Comments


hash

Check sum of the file.

User Comments


hash_type

Name of check sum algorithm used (e.g. "MD5").

User Comments


filesize

Size of the file in bytes.

User Comments


mtime

Last modification time of the file.

User Comments


url

Virtual field for storing the file's URL.

User Comments


data

Virtual field for storing the file's content.

User Comments


METHODS

User Comments


Constructor Methods

User Comments


new_from_filename

$dataobj = EPrints::DataObj::File->new_from_filename( $session, $dataobj, $filename )

Convenience method to get an existing File object for $filename stored in $dataobj.

Returns undef if no such record exists.

User Comments


create_from_data

$dataobj = EPrints::DataObj::File->create_from_data( $session, $data [, $dataset ] )

Create a new File record using $data. If "_content" is defined in $data it will be read from and stored - for possible values see set_file().

User Comments


Class Methods

User Comments


get_system_field_info

$thing = EPrints::DataObj::File->get_system_field_info

Core fields.

User Comments


get_dataset_id

$dataset = EPrints::DataObj::File->get_dataset_id

Returns the id of the EPrints::DataSet object to which this record belongs.

User Comments


get_defaults

$defaults = EPrints::DataObj::File->get_defaults( $session, $data )

Return default values for this object based on the starting data.

User Comments


Object Methods

User Comments


clone

$new_file = $file->clone( $parent )

Clone the $file object (including contained files) and return the new object.

User Comments


remove

$success = $file->remove

Delete the stored file.

User Comments


get_local_copy

$filename = $file->get_local_copy()

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

Will retrieve and cache the remote object if necessary.

User Comments


add_file

$success = $file->add_file( $filepath, $filename [, $preserve_path ] )

Read and store the contents of $filepath at $filename.

If $preserve_path is untrue will strip any leading path in $filename.

User Comments


upload

$bytes = $file->upload( $filehandle, $filename, $filesize [, $preserve_path ] )

Read and store the data from $filehandle at $filename at the next revision number.

If $preserve_path is untrue will strip any leading path in $filename.

Returns the number of bytes read from $filehandle or undef on failure.

User Comments


write_copy

$success = $stored->write_copy( $filename )

Write a copy of this file to $filename.

Returns true if the written file contains the same number of bytes as the stored file.

User Comments


write_copy_fh

$success = $stored->write_copy_fh( $filehandle )

Write a copy of this file to $filehandle.

User Comments


generate_md5

$md5 = $stored->generate_md5

Calculates and returns the MD5 for this file.

User Comments


generate_sha

$digest = $file->generate_sha( [ ALGORITHM ] )

Generate a SHA for this file, see Digest::SHA::PurePerl for a list of supported algorithms. Defaults to "256" (SHA-256).

Returns the hex-encoded digest.

User Comments


add_plugin_copy

$stored->add_plugin_copy( $plugin, $sourceid )

Add a copy of this file stored using $plugin identified by $sourceid.

User Comments


remove_plugin_copy

$stored->remove_plugin_copy( $plugin )

Remove the copy of this file stored using $plugin.

User Comments


get_file

$success = $stored->get_file( CALLBACK )

Get the contents of the stored file - see EPrints::Storage::retrieve().

User Comments


set_file

$content_length = $stored->set_file( CONTENT, $content_length )

Reads data from CONTENT and stores it. Sets the MD5 hash and filesize.

If the write failed returns undef and sets the filesize to 0.

CONTENT may be one of:

 CODEREF - will be called until it returns empty string ("")
 SCALARREF - a scalar reference will be used as-is (expects bytes)
 GLOB - will be treated as a file handle and read with sysread()
 

This method does not check the actual number of bytes read is the same as $content_length.

User Comments


SEE ALSO

EPrints::DataObj and EPrints::DataSet.

User Comments