Catman...::Index(3pm)

πŸ’– Catman...::Index(3pm) πŸ’–

okay bestie, pull up a chair because this one is a whole situation and it's lowkey iconic 🫢 This page is Catman...::Index(3pm) from the User Contributed Perl Documentation, and it's all about the index of every single "Folder" living inside a Catmandu::Store::File::FedoraCommons. Yes, folders. Yes, all of them. No cap. 🌸


✨ NAME ✨

Catmandu::Store::File::FedoraCommons::Index β€” it's literally the Index of all "Folders" in a Catmandu::Store::File::FedoraCommons. That's the whole gig. It's giving organised. πŸ’…


πŸ¦‹ SYNOPSIS πŸ¦‹

okay so here's the vibe, bestie β€” copy this exactly, don't freestyle it:

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 containers
$index->each(sub {
    my $container = shift;

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

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

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

# Get a folder
my $folder = $index->get(1234);

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

$files->each(sub {
    my $file = shift;

    my $name         = $file->_id;
    my $size         = $file->size;
    my $content_type = $file->content_type;
    my $created      = $file->created;
    my $modified     = $file->modified;

    $file->stream(IO::File->new(">/tmp/$name"), file);
});

# Add a file
$files->upload(IO::File->new("<data.dat"),"data.dat");

# Retrieve a file
my $file = $files->get("data.dat");

# Stream a file to an IO::Handle
$files->stream(IO::File->new(">data.dat"),$file);

# Delete a file
$files->delete("data.dat");

# Delete a folders
$index->delete("1234");

so yeah, you set up your $store, you grab your $index, and then you're living β€” listing containers, adding folders, deleting folders, getting folders, grabbing the files inside a folder, uploading, retrieving, streaming, deleting. It's a whole workflow and honestly? obsessed. 😭✨


πŸ‘‘ INHERITED METHODS πŸ‘‘

bestie, this Catmandu::Bag implements the following β€” aka it inherited these bad boys and they're part of the family now:

  • Catmandu::Bag
  • Catmandu::FileBag::Index
  • Catmandu::Droppable
fr fr, that's the list β€” Catmandu::Bag, Catmandu::FileBag::Index, and Catmandu::Droppable. All three, no extras, no notes. πŸŽ€

and that's the whole page, bestie!! πŸ’–βœ¨ this lil' manual page is from perl v5.36.0, dated 2023-02-05, and it's filed under the Catman...::Index(3pm) entry in the User Contributed Perl Documentation. slay, you read the whole thing, main character energy for real πŸ¦‹πŸŒΈπŸ’…

πŸ“¦ where this page comes from