我想通过代码将屏幕截图附加到Bugzilla中的错误。我正在使用J2Bugzilla API但无法找到所需的方法。请建议是否使用Java在Bugzilla中附加文件的任何其他API。
答案 0 :(得分:0)
要使用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();
然后,您可以使用AddAttachment
:
AddAttachment add = new AddAttachment(attachment, bug);
//'bug' is a Bug you have previously retrieved
//'conn' is the BugzillaConnector
conn.executeMethod(add);