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::Upload - Upload

SYNOPSIS

    use Mojo::Upload;

    my $upload = Mojo::Upload->new;
    print $upload->filename;
    $upload->copy_to('/foo/bar.txt');

DESCRIPTION

Mojo::Upload is a container for uploads.

ATTRIBUTES

file

    my $file = $upload->file;
    $upload  = $upload->file(Mojo::File->new);

Returns a Mojo::File object if called without arguments. Returns the invocant if called with arguments.

filename

    my $filename = $upload->filename;
    $upload      = $upload->filename('foo.txt');

Returns a file name like foo.txt if called without arguments. Returns the invocant if called with arguments.

length

    my $length = $upload->length;

Returns the length of the file upload in bytes.

headers

    my $headers = $upload->headers;
    $upload     = $upload->headers(Mojo::Headers->new);

Returns a Mojo::Headers object if called without arguments. Returns the invocant if called with arguments.

name

    my $name = $upload->name;
    $upload  = $upload->name('foo');

METHODS

Mojo::Upload inherits all methods from Mojo::Base and implements the following new ones.

copy_to

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

Copies the uploaded file contents to the given path.

move_to

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

Moves the uploaded file contents to the given path.

slurp

    my $content = $upload->slurp;