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

CatalystX::RequestModel::ContentBodyParser::MultiPart - Parse multipart uploads

SYNOPSIS

TBD

DESCRIPTION

Given a list of uploads and possible form parameters:

[debug] "POST" request for "upload" from "127.0.0.1"
[debug] Body Parameters are:
.-------------------------------------+--------------------------------------.
| Parameter                           | Value                                |
+-------------------------------------+--------------------------------------+
| notes                               | This is the file you seek!           |
'-------------------------------------+--------------------------------------'
[debug] File Uploads are:
.--------------+----------------------------+--------------------+-----------.
| Parameter    | Filename                   | Type               | Size      |
+--------------+----------------------------+--------------------+-----------+
| file         | file.txt                   |                    | 13        |
'--------------+----------------------------+--------------------+-----------'

If you have a request model like:

package Example::Model::UploadRequest;

use Moose;
use CatalystX::RequestModel;

extends 'Catalyst::Model';
content_type 'multipart/form-data';

has notes => (is=>'ro', required=>1, property=>1);  
has file => (is=>'ro', property=>1);

__PACKAGE__->meta->make_immutable();

This will be mapped to an instance of the request model:

$request_model->notes;      # 'This is the file you seek!';
$request_model->file;     # Instance of L<Catalyst::Request::Upload>.

This is basically a subclass of CatalystX::RequestModel::ContentBodyParser::FormURLEncoded with added support for multipart form uploads. You should see the parent file for more details.

EXCEPTIONS

See CatalystX::RequestModel::ContentBodyParser for exceptions.

AUTHOR

See CatalystX::RequestModel.

COPYRIGHT

See CatalystX::RequestModel.

LICENSE

See CatalystX::RequestModel.