use Mojo::Content::MultiPart;
my $multi = Mojo::Content::MultiPart->new;
$multi->parse('Content-Type: multipart/mixed; boundary=---foobar');
my $single = $multi->parts->[4];
$multi->on(part => sub {
my ($multi, $single) = @_;
...
});
Emitted when a new Mojo::Content::Single part starts.
$multi->on(part => sub {
my ($multi, $single) = @_;
return unless $single->headers->content_disposition =~ /name="([^"]+)"/;
say "Field: $1";
});
my $parts = $multi->parts; $multi = $multi->parts([Mojo::Content::Single->new]);
Content parts embedded in this multipart content, usually Mojo::Content::Single objects.
my $bool = $multi->body_contains('foobarbaz');
Check if content parts contain a specific string.
my $size = $multi->body_size;
my $boundary = $multi->build_boundary;
Generate a suitable boundary for content and add it to "Content-Type" header.
my $clone = $multi->clone;
Return a new Mojo::Content::MultiPart object cloned from this content if possible, otherwise return "undef".
my $bytes = $multi->get_body_chunk(0);
Get a chunk of content starting from a specific position. Note that it might not be possible to get the same chunk twice if content was generated dynamically.
my $bool = $multi->is_multipart;
True, this is a Mojo::Content::MultiPart object.
my $multi = Mojo::Content::MultiPart->new;
my $multi
= Mojo::Content::MultiPart->new(parts => [Mojo::Content::Single->new]);
my $multi
= Mojo::Content::MultiPart->new({parts => [Mojo::Content::Single->new]});
Construct a new Mojo::Content::MultiPart object and subscribe to ``read'' event with default content parser.