The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojo::File::Memory - In-Memory File

SYNOPSIS

    use Mojo::File::Memory;

    my $file = Mojo::File::Memory->new('Hello!');
    $file->add_chunk('World!');
    print $file->slurp;

DESCRIPTION

Mojo::File::Memory is a container for in-memory files.

ATTRIBUTES

content

    my $handle = $file->content;
    $file      = $file->content('Hello World!');

METHODS

Mojo::File::Memory inherits all methods from Mojo::File and implements the following new ones.

new

    my $file = Mojo::File::Memory->new('foo bar');

add_chunk

    $file = $file->add_chunk('test 123');

contains

    my $contains = $file->contains('random string');

copy_to

    $file = $file->copy_to('/foo/bar/baz.txt');

Copies the uploaded file contents to the given path and returns the invocant.

get_chunk

    my $chunk = $file->get_chunk($offset);

length

    my $length = $file->length;

move_to

    $file = $file->move_to('/foo/bar/baz.txt');

Moves the uploaded file contents to the given path and returns the invocant.

slurp

    my $string = $file->slurp;