繁体   English   中英

如何使用Java prgramming语言将附件添加到bugzilla?

[英]How to add attachment in to the bugzilla using java prgramming language?

我想通过代码将屏幕快照附加到Bugzilla中的错误。 我正在使用J2Bugzilla API,但找不到所需的方法。 请建议是否还有其他使用Java在Bugzilla中附加文件的API。

要使用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);

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM