Jonathan Steinert > MogileFS-Client-FilePaths-0.02 > MogileFS::Client::FilePaths

Download:
MogileFS-Client-FilePaths-0.02.tar.gz

Dependencies

Annotate this POD

View/Report Bugs
Module Version: 0.02   Source  

NAME ^

MogileFS::Client::FilePaths - Client library for use with FilePaths plugin in MogileFS

SYNOPSIS ^

 use MogileFS::Client::FilePaths;

 # From MogileFS::Client (See its documentation for details)
 $mogc = MogileFS::Client->new(domain => "foo.com::my_namespace",
                               hosts  => ['10.0.0.2', '10.0.0.3']);

 $key   = "/path/to/file";   # The FilePaths plugin lays a path structure on top of standard mogilefs.
 $class = "user_images";     # Files still belong to classes
 $fh = $mogc->new_file($key, $class);

 print $fh $data;

 unless ($fh->close) {
    die "Error writing file: " . $mogc->errcode . ": " . $mogc->errstr;
 }

 # Find the URLs that the file was replicated to.  May change over time.
 @urls = $mogc->get_paths($key);

 # no longer want it?
 $mogc->delete($key);

 # List files in a directory
 @files = $mogc->list("/path/to");

 # Each element is a hashref, see below for more keys.
 @file_names = map { $_->{name} } @files;

DESCRIPTION ^

This module is a subclass of the MogileFS::Client library, it provides a similar interface for extra functionality provided in the FilePaths plugin.

All methods are inhereted and usable from the MogileFS::Client library, with only the exceptions listed below.

METHOD CHANGES ^

new_file

The fourth argument to the new_file method is a hashref of options for this transaction. This module handles a new option called 'meta' which is metadata to be stored along with the file in mogilefs. For example:

 $filehandle = $mogc->new_file($path, $class, $size, {
     meta => {
         mtime => scalar(time),
         foo => "bar",
     },
 });

NEW METHODS ^

list

 @files = $mogc->list($path)

 Given a path, returns a list of files contained in that path. Each element of the returned list is a hashref with the following possible keys:
name

Contains the name of the file

path

Contains the fully qualified path of the file

is_directory

True if item is a directory

is_file

True if item is a file

modified

Value of mtime metadata field stored with this file.

size

Size in bytes for this file.

rename

 $rv = $mogc->rename($oldpath, $newpath)

Attempts to rename $oldpath to $newpath, returns true on success and false on failure.

syntax highlighting: