Jeśli tak, możesz podać kod. Jestem w stanie zrobić prawie wszystko inne, tworząc nowe strony, modyfikując atrybuty strony itp. Ale nie mogę dodawać załączników. Przeczytałem oficjalną wersję conflunce Perl XML-RPC site and discussions, ale wszystkie fragmenty kodu, które tam pokazują, nie działają dla mnie. Oto moja zhakowana próba:Czy ktoś był w stanie uzyskać Confluence.pm, aby dodać załączniki?
# 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";
}
}
Dzięki! Przeniosłem się do innych projektów, ale dziękuję za dodanie wglądu do zbiorowego ... – stephenmm