GitHub API documentation显示了以下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
有什么区别?什么是出于什么目的?
最佳答案 content_url one(从
repo get content API开始)支持
custom media type
application/vnd.github.VERSION.raw
application/vnd.github.VERSION.html
raw_url是第一种媒体类型的快捷方式.
blob_url只能看到files in commits,并且在git repo中存储该文件的内容,而没有媒体类型的概念.