Thanks Dave,

I have in the meantime also come across a working Perl example:

# Description: This scripts sends a newMediaObject request


use strict;
use warnings;
use Data::Dumper;
use XMLRPC::Lite +trace => qw(debug);

my $username = "username";
my $password = "password";
my $blogid   = "blogid";
my $proxyurl = 'http://spica:8080/roller/roller-services/xmlrpc';
my ($buf,$contents);

open(FILE, "/tmp/img.jpg") or die "$!";
while (read(FILE, $buf, 60*57)) {
        $contents .= $buf;
}

my $res = XMLRPC::Lite
->proxy($proxyurl)
->call('metaWeblog.newMediaObject', $blogid, $username, $password,
{ name => "/tmp/img.jpg", type => 'image/jpeg', bits => $contents } )
->result;

if (defined ($res)) {
        print "--success--\\n";
        print Dumper ($res);
} else {
        print "failed: $!";
}

Now if only I could get it working in Ruby, but understand that I
should probably ask elsewhere regarding that.  Thanks again for the
help, and *if* anyone here knows Ruby and is willing to show me a way
to do so in Ruby that would be great.

Thanks again and cheers,
Pieter Steyn


> I'm no Ruby guy, but I according to the pickaexe book, Ruby's
>  FIle.read() returns a string. What you need is a way to turn a file
>  into a byte array. Here's a complete Java example:
>  http://tinyurl.com/2nv8ya
>
>
>  - Dave
>

Reply via email to