LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   How to PUT a file with perl LWP (https://www.linuxquestions.org/questions/linux-software-2/how-to-put-a-file-with-perl-lwp-4175439846/)

markseger 12-03-2012 02:55 PM

How to PUT a file with perl LWP
 
I recently discovered LWP and while the documetation is pretty clear on some things, I'm also finding it lacking in others. Perhaps the problem is http is so extensive you can't document everything and have to let the user rely of getting the details elsewhere.

That said, I'm trying to PUT a file to a web server that is set up to receive one via a REST interface. One first authenticates oneself, gets a token and uses that token with the PUT. I've done this in bash curl, so know I'm doing it correctly.

Using LWP I managed to GET a token and build a put request, so I'm at least using some of the functions correctly. In fact, my first PUT try I got an authentication error and once I got my request formatted correctly the authenticate error went away so I think I'm real close. However the request still fails and therein lies my question - how/where do you specify the data portion of a PUT request? I'm guessing you build an in memory string of data and pass it as a reference, but I have no idea how.

As a curiosity I looked at the source for UserAgent.pm and founds subs for get and post, but no put! Clearly I'm missing something.

-mark

markseger 12-03-2012 03:58 PM

I finally figured it out. Once again, O'Reilly to the rescue: http://oreilly.com/openbook/webclient/ch05.html#42247
-mark


All times are GMT -5. The time now is 07:10 AM.