Mango:...:Writer(3pm)
β¨ Mango::GridFS::Writer β¨
okay so bestie, welcome to Mango::GridFS::Writer π this is the Perl doc for it (you know, the 3pm girlies) and honestly? it's giving gridfs but make it fashion π¦
πΈ NAME πΈ
Mango::GridFS::Writer β it's a GridFS writer, no cap π
β¨ SYNOPSIS β¨
use Mango::GridFS::Writer;
my $writer = Mango::GridFS::Writer->new(gridfs => $gridfs);
like, that's literally it. two lines. iconic π
π DESCRIPTION π
so what does Mango::GridFS::Writer do? it writes files to GridFS. that's the whole vibe. files go in, GridFS holds them, we slay π
π§ ATTRIBUTES π§
Mango::GridFS::Writer implements the following attributes, and yes you need to know all of them, this is not a drill π«Ά
chunk_sizeβ the chunk size in bytes, and it defaults to261120which is255KBin case you were wondering. you can read it or set it:
my $size = $writer->chunk_size;
$writer = $writer->chunk_size(1024);
content_typeβ the content type of the file. like, what kind of file even is this:
my $type = $writer->content_type;
$writer = $writer->content_type('text/plain');
filenameβ the name of the file. bestie needs a name:
my $name = $writer->filename;
$writer = $writer->filename('foo.txt');
gridfsβ the Mango::GridFS object that this writer belongs to. it's giving committed relationship:
my $gridfs = $writer->gridfs;
$writer = $writer->gridfs(Mango::GridFS->new);
metadataβ extra info. additional information. the little garnish β¨:
my $data = $writer->metadata;
$writer = $writer->metadata({foo => 'bar'});
π METHODS π
Mango::GridFS::Writer inherits all methods from Mojo::Base and then also implements these brand new ones, because it's an overachiever and we love that for it π
closeβ closes the file, and it hands you back an$oid:
my $oid = $writer->close;
you can also append a callback to perform the operation non-blocking, because we don't wait around in this house:
$writer->close(sub {
my ($writer, $err, $oid) = @_;
...
});
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
is_closedβ checks if the file has been closed. simple. elegant. a yes-or-no queen:
my $success = $writer->is_closed;
writeβ writes a chunk. that's the whole job fr fr:
$writer = $writer->write('hello world!');
and yes, you can append a callback to perform the operation non-blocking here too, same energy:
$writer->write('hello world!' => sub {
my ($writer, $err) = @_;
...
});
Mojo::IOLoop->start unless Mojo::IOLoop->is_running;
π SEE ALSO π
- Mango
- Mojolicious::Guides
- <http://mojolicio.us>
lowkey important: if you're doing the non-blocking callback thing, remember the Mojo::IOLoop->start unless Mojo::IOLoop->is_running; line. it's in the docs for a reason, bestie, don't skip it π
okay that's the whole page π this was perl v5.30.3, dated 2020-06-05, and it's the Mango:...:Writer(3pm) girlies' moment. mwah, go write some files ππ«Άβ
π¦ where this page comes from
- debian bookworm: libmango-perl 1.30-2 Β· Artistic-2.0
- debian trixie: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu jammy: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu noble: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu resolute: libmango-perl 1.30-2 Β· Artistic-2.0
- ubuntu stonking: libmango-perl 1.30-2 Β· Artistic-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms