NAME

Catmandu::Store::File::FedoraCommons - A Catmandu::FileStore to store files on disk into a Fedora3 server

SYNOPSIS

# From the command line

# Create a configuration file
$ cat catmandu.yml
---
store:
 files:
   package: File::FedoraCommons
   options:
     baseurl: http://localhost:8080/fedora
     username: fedoraAdmin
     password: fedoraAdmin
     namespace: demo
     model: DC
     purge: 1

# Export a list of all file containers
$ catmandu export files to YAML

# Export a list of all files in container 'demo:1234'
$ catmandu export files --bag 1234 to YAML

# Add a file to the container 'demo:1234'
$ catmandu stream /tmp/myfile.txt to files --bag 1234 --id myfile.txt

# Download the file 'myfile.txt' from the container 'demo:1234'
$ catmandu stream files --bag 1234 --id myfile.txt to /tmp/output.txt

# Delete the file 'myfile.txt' from the container 'demo:1234'
$ catmandu delete files --root t/data --bag 1234 --id myfile.txt

# From Perl
use Catmandu;

my $store = Catmandu->store('File::FedoraCommons'
                    , baseurl   => 'http://localhost:8080/fedora'
                    , username  => 'fedoraAdmin'
                    , password  => 'fedoraAdmin'
                    , namespace => 'demo'
                    , purge     => 1);

my $index = $store->index;

# List all folder
$index->bag->each(sub {
    my $container = shift;

    print "%s\n" , $container->{_id};
});

# Add a new folder
$index->add({ _id => '1234' });

# Get the folder
my $files = $index->files('1234');

# Add a file to the folder
$files->upload(IO::File->new('<foobar.txt'), 'foobar.txt');

# Retrieve a file
my $file = $files->get('foobar.txt');

# Stream the contents of a file
$files->stream(IO::File->new('>foobar.txt'), $file);

# Delete a file
$files->delete('foobar.txt');

# Delete a folder
$index->delete('1234');

DESCRIPTION

Catmandu::Store::File::FedoraCommons is a Catmandu::FileStore implementation to store files in a Fedora Commons 3 server. Each Catmandu::FileBag.

METHODS

new(%connection_parameters)

Create a new Catmandu::Store::FedoraCommons. The following connection paramaters can be provided:

baseurl

The location of the Fedora Commons endpoint. Default: http://localhost:8080/fedora

user

The username to connect to Fedora Commons

password

The password to connect to Fedora Commons

namespace

The namespace in which all bag identifiers live. Default: demo

dsnamespace

The namespace used to create new data streams. Default: DS

md5enabled

Calculate and add a MD5 checksum when uploading content. Default: 1

versionable

Make data streams in Fedora versionable. Default: 0

purge

When purge is active, deletion of datastreams and records will purge the content in FedoraCommons. Otherwise it will set the status to 'D' (deleted). Default: 0

model

When a model is set, then descriptive metadata can be added to the File::Store folders. Only one type of model is currenty available 'DC'.

Examples:

$ cat record.yml
---
_id: 1234
title:
  - My title
creator:
  - John Brown
  - Max Musterman
description:
  - Files and more things
...
$ catmandu import YAML to files < record.yml
$ catmandu export files to YAML --id 1234
---
_id: 1234
title:
  - My title
creator:
  - John Brown
  - Max Musterman
description:
  - Files and more things
...
$ catmandu stream foobar.pdf to files --bag 1234 --id foobar.pdf
$ catmandu export files --bag 1234
---
_id: foobar.pdf
_stream: !!perl/code '{ "DUMMY" }'
content_type: application/pdf
control_group: M
created: '1504170797'
format_uri: ''
info_type: ''
location: demo:1234+DS.0+DS.0.0
locationType: INTERNAL_ID
md5: 6112b4f1b1a439917b8bbacc93b7d3fa
modified: '1504170797'
size: '534'
state: A
version_id: DS.0.0
versionable: 'false'
...
$ catmandu stream files --bag 1234 --id foobar.pdf > foobar.pdf

INHERITED METHODS

This Catmandu::FileStore implements:

Catmandu::FileStore
Catmandu::Droppable

The index Catmandu::Bag in this Catmandu::Store implements:

Catmandu::Bag
Catmandu::FileBag::Index
Catmandu::Droppable

The file Catmandu::Bag in this Catmandu::Store implements:

Catmandu::Bag
Catmandu::FileBag
Catmandu::Droppable

SEE ALSO

Catmandu::Store::File::FedoraCommons::Index, Catmandu::Store::File::FedoraCommons::Bag, Catmandu::FileStore