Catman...ti::Bag(3pm)

πŸ“¦
version 1.16 Β· 4 versions
, in debian bookworm, ubuntu noble

πŸ’– Catmandu::Store::File::Multi::Bag πŸ’–

okay bestie, so this is the manual page for Catmandu::Store::File::Multi::Bag, straight out of the User Contributed Perl Documentation, section 3pm. It's a whole vibe and honestly it's giving "I hold your entire filesystem together." πŸŽ€


✨ NAME ✨

Catmandu::Store::File::Multi::Bag β€” it's the index of all the "files" chillin' inside a Catmandu::Store::File::Multi "folder". Like, every file, indexed, accounted for, no strays. πŸ¦‹


🌸 SYNOPSIS 🌸

use Catmandu;

my $store = Catmandu->store('File::Multi' , stores [
    Catmandu->store('File::Simple', root => '/data1/files') ,
    Catmandu->store('File::Simple', root => '/data1/files_copy') ,
]);

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");

okay so literally everything you'd ever wanna do to a folder is right there β€” list it, add it, delete it, grab it, and then dive into the files inside it, upload, retrieve, stream, delete. the whole pipeline, slay. πŸ’…


πŸ‘‘ INHERITED METHODS πŸ‘‘

This Catmandu::Bag implements all of these, no cap:

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

so it's got bag energy, file-bag energy, and droppable energy all stacked on top of each other. main character inheritance fr fr. 🫢


that's the whole page, bestie β€” nothing left out, everything kept, periodt. πŸ’–

sign-off cuteness: this page came from perl v5.36.0, dated 2022-12-10. go forth and index your files, queen. βœ¨πŸŽ€πŸ’œ

πŸ“¦ where this page comes from