如何添加通过SDK来工作项附件,无需使用物理文件? [英] How can I add an attachment via the SDK to a work item without using a physical file?

查看:188
本文介绍了如何添加通过SDK来工作项附件,无需使用物理文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想通过客户端SDK来创建TFS 2010年新的工作项目。

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

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

不过,这需要的文件被安装到放置在任何一个网络访问路径,或磁盘在TFS服务器本身。

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.

在我们的例子中所附加的文件只是一个内存中的BLOB,而不必附件保存到一个物理路径似乎是不必要的,绝对复杂深受广大客户所需要的部署步骤,因为我们需要把他们的文件系统上,然后一旦工作项目已创建随后将其删除。

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.

有没有什么办法来附加文件,而无需将其放置在文件系统上 - ?理想我想,比方说,只是提供一个字节数组,文件名和MIME类型

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?

更新

出现的共识是,这是不可能的 - 而解决办法是写自己的依恋类,它包装起来,以创建磁盘上的临时附件文件的功能:

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.$c$cplex.com/SourceControl/changeset/view/74794#336044

推荐答案

这是不可能的。

有一个很好的实现增加了截图使用临时文件的工作项目:<一href="http://witcustomcontrols.$c$cplex.com/SourceControl/changeset/view/74794#336038">http://witcustomcontrols.$c$cplex.com/SourceControl/changeset/view/74794#336038

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

这篇关于如何添加通过SDK来工作项附件,无需使用物理文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆