如何通过 SDK 将附件添加到工作项而不使用物理文件?

发布于 2024-09-15 12:31:30 字数 762 浏览 0 评论 0原文

我正在尝试通过客户端 SDK 为 TFS 2010 创建一个新的工作项。

在 SDK 中,您可以执行以下操作:

WorkItem item = ...;
item.Attachments.Add(new Attachment("c:\\path\\on\\tfs\\server\\shot.png", "Screen shot"));
item.Save();

但这需要将附加的文件放置在网络可访问路径上,或者放置在 TFS 服务器本身的磁盘上。

在我们的例子中,附加的文件只是内存中的 blob,必须将附件保存到物理路径似乎没有必要,并且肯定会使我们的客户所需的部署步骤变得复杂,因为我们需要将它们放在文件系统上,然后创建工作项后,随后将其删除。

有没有什么方法可以附加文件而不必将其放置在文件系统上 - 理想情况下我正在考虑,比如说,只提供一个字节数组、文件名和 mime 类型?


更新

似乎一致认为这是不可能的 - 解决方法是编写您自己的附件类,该类包含在磁盘上创建临时附件文件的功能:

http://witcustomcontrols.codeplex.com/SourceControl/changeset/view/74794#336044

I'm trying to create a new work item for TFS 2010 via the client SDK.

In the SDK you can do something like this:

WorkItem item = ...;
item.Attachments.Add(new Attachment("c:\\path\\on\\tfs\\server\\shot.png", "Screen shot"));
item.Save();

But this requires the file being attached to be placed on either a network accessible path, or on a disk in the TFS server itself.

In our case the file being attached is just an in-memory blob, and having to save attachments to a physical path seems unnecessary and definitely complicates the deployment steps required by our customers, as we need to put them on the file system, and then subsequently remove them once the work item has been created.

Is there any way to attach a file without having to place it on the file system - ideally I'm thinking of, say, just providing a byte array, file name and mime type?


Update

Appears the consensus is that this is not possible - and the work around is to write your own attachment class, that wraps up the functionality to create a temporary attachment file on the disk:

http://witcustomcontrols.codeplex.com/SourceControl/changeset/view/74794#336044

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

依 靠 2024-09-22 12:31:30

这是不可能的。

使用临时文件向工作项添加屏幕截图有一个很好的实现: http ://witcustomcontrols.codeplex.com/SourceControl/changeset/view/74794#336038

This is not possible.

There is a nice implementation of adding a screenshot to the work item using a temporary file: http://witcustomcontrols.codeplex.com/SourceControl/changeset/view/74794#336038

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文