octokat.js
octokat.js copied to clipboard
Cannot fetch files > 1 mb from GitHub API.
I get the following error message trying to fetch a .json
file that has grown larger than 1mb:
{
"message":"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.",
"errors":[{"resource":"Blob","field":"data","code":"too_large"}]
}
Is there a workaround that exists for this? Any help would be greatly appreciated, thanks in advance!
Any help would be so greatly appreciated.
It seems like https://developer.github.com/v3/git/blobs/#get-a-blob allows you to retrieve larger files.
In order to get the sha for the blob, https://developer.github.com/v3/git/ might be useful. I have not had to use Blobs directly, but it might look something like:
- Get the branch to find the commit sha
- Get the commit for the branch to find the tree sha
- Get the tree corresponding to the commit to find subtrees or the blob sha
- recurse through subtrees if the JSON file is not at the root of the repository
- Get the blob corresponding to the file
- base64decode the blob (or maybe use octokat's
.readBinary()
method)
There are methods on octokat that correspond to each of the GitHub API calls. Examples can be found here: https://github.com/philschatz/octokat.js/blame/master/examples/README.md#L43-L50
Hope that helps!