| Catmandu::Store::File::FedoraCommons(3pm) | User Contributed Perl Documentation | Catmandu::Store::File::FedoraCommons(3pm) |
Catmandu::Store::File::FedoraCommons - A Catmandu::FileStore to store files on disk into a Fedora3 server
# 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');
Catmandu::Store::File::FedoraCommons is a Catmandu::FileStore implementation to store files in a Fedora Commons 3 server. Each Catmandu::FileBag.
Create a new Catmandu::Store::FedoraCommons. The following connection parameters can be provided:
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
This Catmandu::FileStore implements:
The index Catmandu::Bag in this Catmandu::Store implements:
The file Catmandu::Bag in this Catmandu::Store implements:
Catmandu::Store::File::FedoraCommons::Index, Catmandu::Store::File::FedoraCommons::Bag, Catmandu::FileStore
| 2023-02-05 | perl v5.36.0 |