chicks
chicks

Reputation: 2463

Can HTTP::Tiny be used to upload files?

Can HTTP::Tiny be used to upload files? Nothing in the HTTP::Tiny docs or any of the examples I can find via google show how to upload files with this Perl module. Is it possible? Are there any better HTTP::Tiny examples?

Upvotes: 3

Views: 1142

Answers (1)

cjm
cjm

Reputation: 62089

Not easily. HTTP::Tiny contains no support for the multipart/form-data content type required by file uploads. (That's one of the reasons it's called "Tiny".)

You could upload a file using the request method, but you'd have to supply the encoded content yourself and also add a multipart/form-data content-type header.

This would be something like

$response = $tiny->request('POST', $url, {
        content => $multipart_form_data,
        headers => {'content-type' => 'multipart/form-data'},
    }
);

Correctly populating $multipart_form_data is left as an exercise for the reader. :-)

Upvotes: 5

Related Questions