MATSUNO★Tokuhiro"'<xmp> > HTTP-Body-Builder > HTTP::Body::Builder::MultiPart

Download:
HTTP-Body-Builder-0.04.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Source  

NAME ^

HTTP::Body::Builder::MultiPart - multipart/form-data

SYNOPSIS ^

    use HTTP::Body::Builder::MultiPart;

    my $builder = HTTP::Body::Builder::MultiPart->new();
    $builder->add_content('x' => 'y');
    $builder->as_string;
    # => x=y

METHODS ^

my $builder = HTTP::Body::Builder::MultiPart->new()

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.

For the content parameter, each key/value pair in this hashref will be added to the builder by calling the add_content method.

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');
$builder->add_content($key => $value);

Add new parameter in raw string.

$builder->add_file($key => $real_file_name);

Add $real_file_name as $key.

$builder->as_string();

Generate body as string.

$builder->write_file($filename);

Write the content to $filename.

syntax highlighting: