Skip Menu |
 

This queue is for tickets about the BZ-Client CPAN distribution.

Report information
The Basics
Id: 121581
Status: resolved
Priority: 0/
Queue: BZ-Client

People
Owner: dean [...] fragfest.com.au
Requestors: raphael.crochet [...] actia.fr
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: 4.4002



Subject: [BUG] BZ::Client, unable to attach zip file to a bug
Date: Tue, 9 May 2017 10:25:52 +0000
To: "bug-BZ-Client [...] rt.cpan.org" <bug-BZ-Client [...] rt.cpan.org>
From: Raphael Crochet <raphael.crochet [...] actia.fr>
Download (untitled) / with headers
text/plain 3.9k
Environment This is perl 5, version 20, subversion 1 (v5.20.1) built for MSWin32-x86-multi-thread-64int BZ::Client is up to date. (4.4001) More than a bug, it is a lack of code. In fact, all binary format (zip, jpg, png, ...) can't be attached to a bug thanks to BZ::Client. We can serialize data in base64 if we encode it manually (client code), but the XMLRPC Bugzilla server is not able to recognize it as base64. Bugzilla can't give back the original file and the result seems to be corrupted. The best that I could get is the encode base64 content, not he original file. I tried to add the tag <base64> ...</base64> directly into data, but it can't work as data is considered ... as data and tags are escaped with &lt;base64&gt;. The only solution I saw was to modify the XMLRPC client at serialization of the request (like it is already done for other data types). I put in attachment, the module I patched to get the stuff done. Following code snippet shows an example that works fine with patched version. $client = BZ::Client->new( url => $url, autologin => 0 ); sub addAttachment() { my ($id, $file) = @_; open (FILE, "<",$file) or die "$0: $!"; binmode FILE; my $data = join('', <FILE>); close FILE; my $file_attach=BZ::Client::XMLRPC::base64->new($data); my $filename = basename($file); # file name if (DEBUG) {print "AddAttachment: search for request: $id\n";} my $bugId = getBugBySummary($id); # get bug by summary description if (!defined $bugId) { print "$0: Not found request for: $id \n"; die "$0: AddAttachment: Error, request $id not found to attach data!\n"; } # hash map containing parameter of bugzilla attachment my %params = ( ids => [ $bugId ], file_name => $filename, content_type => 'application/zip', summary => $filename, data => $file_attach, ); my $response; eval { $response = $client->api_call( 'Bug.add_attachment', \%params ); print "$0: AddAttachment: $filename processed in BugZilla.\n"; }; if ($@) { print "$0: ERROR Upload file: $@->{'message'}\n"; } } Regards Raphaël CROCHET Technology Department Fixe : +33 (0)5 82 08 05 42 [logo_ACTIA_mail_2017] ACTIA Automotive (siège social) 5, rue Jorge Semprun B.P. 74215 - 31432 TOULOUSE cedex 4 (FRANCE) http://www.actia.com<http://www.actia.com/> [icon_mail_youtube]<http://www.youtube.com/ActiaOfficialCom> [icon_mail_linkedin] <http://www.linkedin.com/company/actia> [icon_mail_web] <http://www.actia.com/> ............................................. Ce courrier électronique ainsi que tout fichier qui y est joint est destiné exclusivement aux personnes ou institutions dont le nom figure ci-dessus et peut contenir des informations protégées par le secret professionnel, dont la divulgation est strictement prohibée. Tout message électronique est susceptible d'altération. Actia décline toute responsabilité au titre de ce message. Le contenu de ce message ne représente en aucun cas un engagement de la part de notre société. Si vous n'êtes pas destinataire, nous vous avisons que sa lecture, sa reproduction ou sa distribution sont strictement interdites. Nous vous prions en conséquence de nous aviser immédiatement par retour de ce courrier et de supprimer ce message et tout document joint de votre société. Merci. This email message and its enclosures is for the sole use of the intended recipient(s) and may contain confidential and privileged information. Any unauthorized review, use, disclosure or distribution is prohibited. Any e-mail message is subject to alteration. Actia disclaims all liability in connection with this message. The content of this message does not represent any commitment from our company. If you are not the intended recipient, please contact the sender by reply e-mail and destroy all copies of the original message with its enclosures. Thank you.
Download (untitled) / with headers
text/html 35.1k

Message body is not shown because it is too large.

Download image001.jpg
image/jpeg 9.5k
image001.jpg
Download image002.jpg
image/jpeg 1.4k
image002.jpg
Download image003.jpg
image/jpeg 1.3k
image003.jpg
Download image004.jpg
image/jpeg 1.8k
image004.jpg
Download XMLRPC.PM
text/x-perl 11.4k

Message body is not shown because sender requested not to inline it.

Download (untitled) / with headers
text/plain 103b
thats very good feedback. i will look at your code and put together a new version in the next few days.
which verson of bugzilla are you running against?
Subject: RE: [rt.cpan.org #121581] [BUG] BZ::Client, unable to attach zip file to a bug
Date: Mon, 15 May 2017 09:05:38 +0000
To: "bug-BZ-Client [...] rt.cpan.org" <bug-BZ-Client [...] rt.cpan.org>
From: Raphael Crochet <raphael.crochet [...] actia.fr>
Download (untitled) / with headers
text/plain 397b
version 5.0.3 -----Message d'origine----- De : Dean Hamstead via RT [mailto:bug-BZ-Client@rt.cpan.org] Envoyé : lundi 15 mai 2017 00:09 À : Raphael Crochet <raphael.crochet@actia.fr> Objet : [rt.cpan.org #121581] [BUG] BZ::Client, unable to attach zip file to a bug <URL: https://rt.cpan.org/Ticket/Display.html?id=121581 > which verson of bugzilla are you running against?
Download (untitled) / with headers
text/plain 133b
I have just pushed code to github that is inspired by your provided code. Once travis is finished, I will make a new release on CPAN.
Download (untitled) / with headers
text/plain 435b
I have just released 4.4002 which contains functionality inspired by your code. Attachments are handled with BZ::Client::Bug::Attachment, specifically the add() function. I have added the convenience of just specifying a local filename and BZ::Client will slurp it up, encode it and transmit it. Or you can do the same yourself if you so desire, or generate the file content entirely in memory and transmit it. Let me know how you go
Closing as fixed. Please let me know if you have any issues


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.