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/fedora
  • user β€” the username you use to connect to Fedora Commons
  • password β€” the password you use to connect to Fedora Commons
  • namespace β€” the namespace that all bag identifiers live inside. Default: demo
  • dsnamespace β€” the namespace used when creating new data streams. Default: DS
  • md5enabled β€” calculate and add an MD5 checksum whenever you upload content. Default: 1
  • versionable β€” make data streams in Fedora versionable. Default: 0
  • purge β€” when purge is active, deleting datastreams and records purges the content in FedoraCommons. otherwise it just sets the status to 'D' (deleted). Default: 0
  • model β€” when a model is set, descriptive metadata can be added to the File::Store folders. 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::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

look at all those inherited traits. generational talent fr 🧬


πŸ‘‘ SEE ALSO πŸ‘‘

  • Catmandu::Store::File::FedoraCommons::Index
  • Catmandu::Store::File::FedoraCommons::Bag
  • Catmandu::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