Catman...ommons(3pm)
π Catman...ommons(3pm) π
okay bestie so this is a page from the User Contributed Perl Documentation and it's section 3pm of the manual. It's literally called Catman...ommons, which is giving β¨truncated filename energyβ¨ but we move.
π NAME π
Catmandu::Store::File::FedoraCommons β a Catmandu::FileStore that stores files on disk... into a Fedora3 server. yes, into it. we love a container.
πΈ SYNOPSIS πΈ
first up, from the command line, bestie:
# 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');
like, look at all that. folders, files, uploading, streaming, deleting. it's giving full lifecycle π
π¦ DESCRIPTION π¦
Catmandu::Store::File::FedoraCommons is a Catmandu::FileStore implementation whose whole thing is storing files in a Fedora Commons 3 server. Each Catmandu::FileBag.
no fr I know, the sentence just kinda stops there π that's literally how it is in the source, so I'm keeping it, bestie. not my business to finish other people's sentences.
β¨ METHODS β¨
π new(%connection_parameters)
make yourself a brand new Catmandu::Store::FedoraCommons. here's the connection parameters you can pass in, one by one, no skips:
baseurlβ where the Fedora Commons endpoint lives. Default:http://localhost:8080/fedorauserβ the username you use to connect to Fedora Commonspasswordβ the password you use to connect to Fedora Commonsnamespaceβ the namespace that all bag identifiers live inside. Default:demodsnamespaceβ the namespace used when creating new data streams. Default:DSmd5enabledβ calculate and add an MD5 checksum whenever you upload content. Default:1versionableβ make data streams in Fedora versionable. Default:0purgeβ when purge is active, deleting datastreams and records purges the content in FedoraCommons. otherwise it just sets the status to'D'(deleted). Default:0modelβ when a model is set, descriptive metadata can be added to theFile::Storefolders. only one type of model is currently available:'DC'.
and here are the model examples, verbatim, because I would never do you like that:
$ 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
that _stream: !!perl/code '{ "DUMMY" }' line is so unserious and yet it's canon π
π INHERITED METHODS π
this Catmandu::FileStore implements:
Catmandu::FileStoreCatmandu::Droppable
the index Catmandu::Bag in this Catmandu::Store implements:
Catmandu::BagCatmandu::FileBag::IndexCatmandu::Droppable
the file Catmandu::Bag in this Catmandu::Store implements:
Catmandu::BagCatmandu::FileBagCatmandu::Droppable
look at all those inherited traits. generational talent fr π§¬
π SEE ALSO π
Catmandu::Store::File::FedoraCommons::IndexCatmandu::Store::File::FedoraCommons::BagCatmandu::FileStore
that's the whole page bestie, you ate it π go store some files. this was perl v5.36.0, dated 2023-02-05, and yes I'm signing off like a true main character: periodt. π«ΆπΈπ¦
π¦ where this page comes from
- debian bookworm: libcatmandu-fedoracommons-perl 0.5-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- debian trixie: libcatmandu-fedoracommons-perl 0.5-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu noble: libcatmandu-fedoracommons-perl 0.5-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu resolute: libcatmandu-fedoracommons-perl 0.5-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- ubuntu stonking: libcatmandu-fedoracommons-perl 0.5-2 Β· Artistic-1.0-Perl OR GPL-1.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms