我正在使用此API更新我的repo上的文件,它要求我为要更新的文件提供有效的SHA blob:
http://developer.github.com/v3/repos/contents/
如何找到特定文件的SHA blob?我在测试帐户的testrepo中提供了什么,test.txt文件的SHA blob是什么?
https://github.com/testacc01/testrepo01
非常感谢!
我想知道如何通过 GitHub API 获取文件的所有提交/版本(即提交/版本的内容)。
我想出了一种方法,相当于另一个问题的答案。
问题是这使用了“内容”API,每个文件的上限为 1 MB(如果您尝试访问大于 1 MB 的文件,则会收到此错误消息:“ This API returns blobs up to 1 MB in size. The requested blob is too large to fetch via the API, but you can use the Git Data API to request blobs up to 100 MB in size.”)
因此,要获取大于 1 MB(最多 100 MB)的文件,您需要使用“blob”API,但我不知道如何以与内容 API 相同的方式使用它。
即,给定文件的特定提交,您如何使用“blob”API 获取该文件的内容?
当我尝试使用Github.js从大于 ~1MB 的文件中 getSha(以及随后的 getBlob)时,出现 403 错误。文件大小有限制吗?代码如下:
var gh = new GitHub({
username: username,
password: password
});
// get the repo from github
var repo = gh.getRepo('some-username','name-of-repo');
// get promise
repo.getSha('some-branch', 'some-file.json').then(function(result){
// pass the sha onto getBlob
return repo.getBlob(result.data.sha);
}).then(function(result){
do_something_with_blob(result.data);
});
Run Code Online (Sandbox Code Playgroud)
GitHub API 表示它支持最大 100MB 的 blob,但我在Github.js 文档中找不到任何有关文件大小限制的信息。此外,这些文件来自私人 Github 存储库。