[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [handle-dev] Batch Uploading




There is a good article at:

http://perl.about.com/compute/perl/library/weekly/aa020600e.htm

on how to manipulate MIME content with Perl. It talks about email messages,
but basically it should be the same thing for HTTP POSTing. The Perl MIME
libraries will help you Base 64 encode the message, then you post it using
the LWP modules, receive it on the other end, and then decode it...

HTH,

- steve

Stephen Petschulat
E-Business Architect
IBM Pacific Development Centre
4611 Canada Way
Phone: 1-604-297-3231



                                                                                                                             
                    Tim Keefer                                                                                               
                    <tkeefer@allenpress.com>       To:     handle-dev@cnri.reston.va.us                                      
                    Sent by:                       cc:                                                                       
                    handle-dev-admin@cnri.re       Subject:     [handle-dev] Batch Uploading                                 
                    ston.va.us                                                                                               
                                                                                                                             
                                                                                                                             
                    20/02/2001 10:23 AM                                                                                      
                    Please respond to Tim                                                                                    
                    Keefer                                                                                                   
                                                                                                                             
                                                                                                                             



Hi all,
I am constructing a script to upload our XML metadata files to CrossRef.
At the meeting in New York Mark suggested that Perl's LWP module would
post the metadata file to CrossRef. I'm not exactly sure how this is
done. Below is some Perl code that I have put together that posts data
to the web server. Does anyone know how to post multi-part form data
using perl? I have looked through all the Perl books and they don't
touch on this topic. Any help is appreciated, thanks.

  # Create a user agent object
  use LWP::UserAgent;
  $ua = new LWP::UserAgent;
  $ua->agent("AgentName/0.1 " . $ua->agent);

  # Create a request
  my $req = new HTTP::Request POST =>
'http://deposit.crossref.org/xmlbatch/LoadXML';
  $req->content_type('multipart/form-data');

$req->content('login_passwd=<login>&name_auth=<auth>&login_id=<login_id>');

  # Pass request to the user agent and get a response back
  my $res = $ua->request($req);

  # Check the outcome of the response
  if ($res->is_success) {
      print $res->content;
  } else {
      print "Unable to retrieve response\n";
  }

--
_____________________________________________________________________
Tim Keefer                                  Allen Press, Inc.
Electronic Publishing              1041 New Hampshire
http://www.allenpress.com        Lawrence, KS 66044
_____________________________________________________________________



_______________________________________________
handle-dev mailing list
handle-dev@cnri.reston.va.us
http://www.cnri.reston.va.us/mailman/listinfo/handle-dev





_______________________________________________
handle-dev mailing list
handle-dev@cnri.reston.va.us
http://www.cnri.reston.va.us/mailman/listinfo/handle-dev