Hello,
A little while back someone posted about how to attach files to
tickets using the soap interface. in perl you can use the following
code:
my $h_result = undef;
my $refh_attachment = undef;
if( open( ATTACHMENT_SEND, '<'t read from file handle for
\"".$filepath."\": " . $! . ".\n";
} else {
$refh_attachment = { 'name' => undef, 'contents' => []};
$refh_attachment->{'name'} = SOAP::Data->type(
'xsd:string' => basename( $filepath ));
push( @{ $refh_attachment->{'contents'}}, map{
SOAP::Data->type('xsd:byte' => $_ )} @{ $refar_byte });
}
} else {
warn "Can't set file handle to binary mode for
\"".$filepath . "\": " . $! . ".\n";
}
close( ATTACHMENT_SEND );
} else {
warn "Can't open file \"".$filepath."\" for reading: ".$!.".\n";
}
if( defined( $refh_attachment )) {
if( !defined( $h_result =
$self->{soap}->addAttachmentsToIssue( $self->{authToken},$issueid,
$refh_attachment->{ 'name' }, $refh_attachment->{ 'contents' })) ||
$h_result->fault()){
print "Unable to attach files to new issue
\"".$issueid."\" : ". ( defined( $h_result ) ?
$h_result->faultstring() : "unknown cause." )."\n";
} else {
#print "Added attachments to issue \"".$issueid."\".\n";
}
}
This works great, with one minor issue. It is way too slow to be
useable. It immediately pegs my cpu to the limit, and uses almost all
of the memory that it can. not to mention the fact that if the f ile
is larger than about 1 meg it is the program dies, and anything below
that limit takes several minutes to do. I've narrowed the inital
problem down to the line:
push( @{ $refh_attachment->{'contents'}}, map{
SOAP::Data->type('xsd:byte' => $_ )} @{ $refar_byte });
Which as far as i can tell goes through the unpacked array of bytes,
byte by byte and stuffs it into the attachment->{contents} as soap
bytes (which are much larger than regular bytes as they contain
definition data as well as the bytes. I was just hopeing someone might
be able to help me figure out how to attach files to an issue more
efficiently. There are times where i will need to attach a file that
is 20-50 megs, and the slowdown and cpu/mem use is just unacceptable.
I'm thinking that sending the data as a byte array might not be the
best way to transfer this data across a soap interface. I'm
considering patching the code on the soap plugin, to accept the data
as a base64 mime encoded string. rathar than a gigantic array of
bytes. If anyone else can think of a way of attaching files that
doesn't require patching the soap plugin i'd love to hear it. or if
you thinks base64 mime encoded strings are the best way to go i'd also
like to know what you think is a better route. Also has anyone else
ran into the same problem or am i doing something wrong?
-Dylan
_______________________________________________
Jira-developer mailing list
Jira-developer@lists.atlassian.com
To unsubscribe or change your options visit this page:
http://lists.atlassian.com/mailman/listinfo/jira-developer