Perl: LWP Post request

warrior32
warrior32 used Ask the Experts™
on
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--
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®

Author

Commented:
I'm trying to upload a file, in the above example the file name is texas.txt
This link should help with, what you are looking for:

http://www.perl.com/pub/a/2002/08/20/perlandlwp.html?page=2

Author

Commented:
Any idea on how to put the code together?

Author

Commented:
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?

Author

Commented:
Some code examples by the person would have better than just a link

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial