我想通过代码在Bugzilla中附加一个截图。我正在使用J2Bugzilla API,但无法找到所需的方法。请建议是否有任何其他API使用Java在Bugzilla中附加文件。如何使用java prgramming语言将附件添加到bugzilla中?
回答
要附加与J2Bugzilla任何文件,你必须先创建一个Attachment
:
byte[] data = ...;//Read the data as a byte array from the image file
AttachmentFactory attachmentFactory = new AttachmentFactory();
Attachment attachment = attachmentFactory.newAttachment()
.setData(data)
.setMime("...")//Set the appropriate MIME type for the image format
.setSummary("My screenshot")
.createAttachment();
然后,您可以将其添加到现有的bug报告使用AddAttachment
:
AddAttachment add = new AddAttachment(attachment, bug);
//'bug' is a Bug you have previously retrieved
//'conn' is the BugzillaConnector
conn.executeMethod(add);
Bugilla版本3.6的这个工作吗? – 2013-05-03 06:25:15
不,它不会像[WebService文档](http://www.bugzilla.org/docs/3.6/en/html/api/Bugzilla/WebService/Bug.html)所示。不过,这可以在API文档中更好地解释。 – 2013-05-03 15:25:01
该代码适用于哪个版本? – 2013-06-18 08:58:40
你找到解决方案,你可以分享吗? 我使用的是Python模块超过XMLRPC与Bugzilla的交互 https://git.fedorahosted.org/git/python-bugzilla.git 我Bugzilla的版本是4.2.3 通过使用add_attachment方法我可以上传具有不同扩展名(.zip,.jpg等)的文件,但上传的文件已损坏。所以,我不确定这个Bugzilla附件API是否稳定。 – Khokhar 2014-01-10 14:52:18