如何从VSO存储库获取文件链接 [英] How to get a link to a file from a VSO repo

查看:70
本文介绍了如何从VSO存储库获取文件链接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我浏览GitHub存储库时,我可以从浏览器复制URL,并可以像这样共享它- https://github.com/zlatko- michailov/onesql/blob/master/lang/src/onesql.syntax.ts .文件内容在http响应流中返回,没有任何修饰.

When I browse a GitHub repo, I can copy the URL from the browser, and I can share it like this - https://github.com/zlatko-michailov/onesql/blob/master/lang/src/onesql.syntax.ts. The file content is returned in the http response stream without any decorations.

如何为VSO回购做同样的事情?如果我需要稍微调整一下URL,就可以了.

How can I do the same thing for a VSO repo? If I have to tweak the URL a little bit, that's OK.

我看到浏览器使用此处记录的REST API-

I see the browser uses a REST API that is documented here - https://docs.microsoft.com/en-us/rest/api/azure/devops/git/items/get?view=azure-devops-rest-5.0. I played with different combinations of includeContent, $format, download, etc., but I could only get the content as a separate download, not in the http response body.

主题文件是一些CSV数据,客户端是Excel,它似乎无法处理下载.

The subject file is some CSV data, and the client is Excel, which doesn't seem to be able to handle downloads.

推荐答案

我解决了自己的问题.无需创建供稿.

I solved my own problem. There is no need to create a feed.

获取原始文件的API是sourceProviders.链接在这里:

The API that fetches raw files is sourceProviders. The link is here: https://docs.microsoft.com/en-us/rest/api/azure/devops/build/source%20providers/get%20file%20contents?view=azure-devops-rest-5.0

它的文档记录不是很好-缺少所需参数的示例.棘手的是sourceProvider.它必须是tfsgit.跳过serviceEndpointId对我有用.

It is not very well documented - examples for the required parameters are missing. The tricky one is sourceProvider. It has to be tfsgit. Skipping serviceEndpointId worked for me.

这是模式:

GET https://dev.azure.com/{organization}/{project}/_apis/sourceProviders/tfsgit/filecontents?&repository={repository}&commitOrBranch={commitOrBranch}&path={path}&api-version=5.0-preview.1

这篇关于如何从VSO存储库获取文件链接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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