Link to home
Start Free TrialLog in
Avatar of warrior32
warrior32Flag for Afghanistan

asked on

Perl: LWP Post request

In perl, using
my $ua = LWP::UserAgent->new();
how would I create a POST request using the below as the data to POST.  I am having trouble formulating the request.
The URL to call is   http://mystorage.host.company.com/storage/1234

POST /storage/1234 HTTP/1.0
Host: mystorage.host.company.com
Content-Type: multipart/form-data; boundary=BOUNDARY
Content-Length: 289

--BOUNDARY
Content-Disposition: form-data; name="data"; filename="texas.txt"
Content-Type: text/plain

--BOUNDARY--
Avatar of warrior32
warrior32
Flag of Afghanistan image

ASKER

I'm trying to upload a file, in the above example the file name is texas.txt
ASKER CERTIFIED SOLUTION
Avatar of vikaskhoria
vikaskhoria
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Any idea on how to put the code together?
if using something like the following code

my $req = HTTP::Request->new(POST => $URI);
  $req->content_type($contentType);
 

how would I pass in the values under Boundary?
--BOUNDARY
Content-Disposition: form-data; name="data"; filename="texas.txt"
Content-Type: text/plain

--BOUNDARY--

Would I need to use the $req->content function? If so how would I use it?
Some code examples by the person would have better than just a link