gpt4 book ai didi

java - 如何使用java编程语言将附件添加到bugzilla中?

转载 作者:行者123 更新时间:2023-12-01 04:49:23 25 4
gpt4 key购买 nike

我想通过代码附加 Bugzilla 中错误的屏幕截图。我正在使用 J2Bugzilla API,但无法找到所需的方法。请建议是否有任何其他 API 可以使用 Java 在 Bugzilla 中附加文件。

最佳答案

要使用 J2Bugzilla 附加任何文件,您必须首先创建一个附件:

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);

关于java - 如何使用java编程语言将附件添加到bugzilla中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15243168/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com