Uploading multiple files using LWP
simon at thegestalt.org
Tue Aug 10 07:38:33 BST 2010
I want to POST multiple files to an API endpoint.
[ name => 'Gisle Aas',
email => 'gisle at aas.no',
gender => 'M',
born => '1964',
perc => '3%',
Multivalued form fields can be specified by either repeating the field
name or by passing the value as an array reference.
The POST method also supports the multipart/form-data content used for
Form-based File Upload as specified in RFC 1867. You trigger this
content format by specifying a content type of 'form-data' as one of
the request headers. If one of the values in the $form_ref is an array
reference, then it is treated as a file part specification with the
[ $file, $filename, Header => Value... ]
[ undef, $filename, Header => Value,..., Content => $content ]
Which means, as I understand it (and experimental evidence backs me
up), that I can't post multiple files because an array ref is used for
file attributes not multiple instances of files and an array ref of
array refs just doesn't work.
Is there some easy way of doing this or am I going to have to do
something mildly convoluted, possibly involving HTML::Form?
More information about the london.pm