如果是这样,您可以提供代码。我几乎可以做任何其他事情,从创建新页面,修改页面属性等。但我似乎无法添加附件。我已经阅读了官方conflunce Perl XML-RPC site and discussions,但他们在那里展示的所有代码片段似乎对我都不起作用。这是我对它的黑客攻击:
# The following command sort of worked:
# ~/bin/wikitool.pl -action attach_file -url $MYURL
# IT attached something but the file was empty
sub attach_file {
my $confluence = XMLRPC::Lite->proxy($opts{server}."rpc/xmlrpc");
my $token = $confluence->call("confluence1.login", $opts{login}, $opts{password})->result();
# Fetch page
my $page = FetchPage($opts{title});
if (not $page) {
dbg("$opts{title} page is missing.","FATAL");
}
my $pageId = SOAP::Data->type( string => $$page{id} );
my $filename = "$ENV{HOME}/tmp/tmp0.gif";
my $metadata = {
fileName => $filename,
contentType => "image/gif",
comment => "Some random GIF",
};
if (not open FILE, "< $filename") {
dbg("Could not open file $filename: $!\n","FATAL");
}
binmode FILE;
my $data;
$data .= $_ while (<FILE>);
my $call = $confluence->addAttachment($pageId, $metadata, $data);
my $fault = $call->fault();
if (defined $fault) {
dbg("could not attach $filename" . $call->faultstring(), "FATAL");
}
else {
print "attached $filename\n";
}
}
答案 0 :(得分:5)
你有95%的路在那里。给我的秘诀:
$data .= $_ while (<FILE>);
my $escaped_data = new RPC::XML::base64($data);
my $call = $confluence->addAttachment($pageId, $metadata, $escaped_data);
我确信现在为时已晚,无法提供帮助,但也许其他人有一天会碰到它。
答案 1 :(得分:0)
试着看看Chery Chase使用SOAP代替RPC来附件。
在讨论中见http://confluence.atlassian.com/display/DISC/Perl+XML-RPC+client。
答案 2 :(得分:0)
xml-rpc现在已在合并中弃用。许多功能目前在xml-rpc界面中不起作用。肥皂下的更多作品。