VSO中的分块上传

时间:2017-03-03 07:28:42

标签: tfs azure-devops

enter image description here任何人都可以告诉我如何在VSO上以块的形式上传文件

https://www.visualstudio.com/en-us/docs/integrate/api/wit/attachments#chunked-upload [下面是我已经使用的代码,但我在UpdateWorkItemAsync方法中遇到异常......异常 - :{“TF237136:文件附件不存在,或者您没有权限读取它。”}

2 个答案:

答案 0 :(得分:1)

 var u = new Uri("https://v-vabhan.visualstudio.com/");
VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, pad));
var connection = new VssConnection(u, c);
var workItemTracking = connection.GetClient<WorkItemTrackingHttpClient>();var attachment = workItemTracking.CreateAttachmentAsync("D:\\Area.xml","chunked").Result;
JsonPatchDocument patchDocument = new JsonPatchDocument();
patchDocument.Add(new JsonPatchOperation()
{
Operation = Operation.Add,
Path = "/relations/-",
Value = new
{
rel = "AttachedFile",
url = attachment.Url,
attributes = new 
{ 
comment = "VanDelay Industries - Spec" 
}
}
});
WorkItem result = workItemTracking.UpdateWorkItemAsync(patchDocument, id).Result;
Console.WriteLine("Done attachment.........."+result.Url);

答案 1 :(得分:0)

试试这段代码:

  1. 创建.net应用程序(例如控制台应用程序)
  2. 安装Microsoft Team Foundation Server Extended Client
  3. 代码:

    var u = new Uri("https://xxx.visualstudio.com");
    VssCredentials c = new VssCredentials(new Microsoft.VisualStudio.Services.Common.VssBasicCredential(string.Empty, "[PAT]"));
    var connection = new VssConnection(u, c);
    var workItemTracking = connection.GetClient<WorkItemTrackingHttpClient>();
    var attachement= workItemTracking.CreateAttachmentAsync("D:\\WebAPITest2.zip", "chunked").Result;