GitHub API中的blob_url、raw_url和contents_url有何区别?

6

GitHub API文档展示了API调用的一个回答示例。

  "files": [
    {
      "sha": "bbcd538c8e72b8c175046e27cc8f907076331401",
      "filename": "file1.txt",
      "status": "added",
      "additions": 103,
      "deletions": 21,
      "changes": 124,
      "blob_url": "https://github.com/octocat/Hello-World/blob/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
      "raw_url": "https://github.com/octocat/Hello-World/raw/6dcb09b5b57875f334f61aebed695e2e4193db5e/file1.txt",
      "contents_url": "https://api.github.com/repos/octocat/Hello-World/contents/file1.txt?ref=6dcb09b5b57875f334f61aebed695e2e4193db5e",
      "patch": "@@ -132,7 +132,7 @@ module Test @@ -1000,7 +1000,7 @@ module Test"
    }
  ]

现在我想要获取答案单个文件的内容。
从这三个链接中选择哪一个?
  • blub_url
  • raw_url
  • contents_url
它们有什么区别?每个链接的用途是什么?
1个回答

3

content_url 是从 repo get content API 中的一个,支持自定义媒体类型

application/vnd.github.VERSION.raw
application/vnd.github.VERSION.html

raw_url是指向这些媒体类型中的第一个的快捷方式。

blob_url仅适用于提交文件,并将该文件的内容作为存储在git存储库中的内容提供,没有媒体类型的概念。


网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接