HTTP::Body::Builder::MultiPart - multipart/form-data
use HTTP::Body::Builder::MultiPart; my $builder = HTTP::Body::Builder::MultiPart->new(); $builder->add_content('x' => 'y'); $builder->as_string; # => x=y
Create a new HTTP::Body::Builder::MultiPart instance.
The constructor accepts named arguments as a hash. The allowed parameters are content and files. Each of these parameters should in turn be a hashref.
content
files
For the content parameter, each key/value pair in this hashref will be added to the builder by calling the add_content method.
add_content
For the files parameter, the keys are parameter names and the values are filenames.
If the value of one of the content hashref's keys is an arrayref, then each member of the arrayref will be added separately.
HTTP::Body::Builder::MultiPart->new( content => {'a' => 42, 'b' => [1, 2]}, files => {'x' => 'path/to/file'}, );
is equivalent to the following:
my $builder = HTTP::Body::Builder::MultiPart->new; $builder->add_content('a' => 42); $builder->add_content('b' => 1); $builder->add_content('b' => 2); $builder->add_files('x' => 'path/to/file');
Add new parameter in raw string.
Add $real_file_name as $key.
$real_file_name
$key
Generate body as string.
Write the content to $filename.
$filename
To install HTTP::Body::Builder, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Body::Builder
CPAN shell
perl -MCPAN -e shell install HTTP::Body::Builder
For more information on module installation, please visit the detailed CPAN module installation guide.