Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot fetch files > 1 mb from GitHub API. #261

Open
johncade opened this issue Apr 9, 2018 · 2 comments
Open

Cannot fetch files > 1 mb from GitHub API. #261

johncade opened this issue Apr 9, 2018 · 2 comments

Comments

@johncade
Copy link

johncade commented Apr 9, 2018

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!

@johncade
Copy link
Author

Any help would be so greatly appreciated.

@philschatz
Copy link
Owner

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:

  1. Get the branch to find the commit sha
  2. Get the commit for the branch to find the tree sha
  3. Get the tree corresponding to the commit to find subtrees or the blob sha
  4. recurse through subtrees if the JSON file is not at the root of the repository
  5. Get the blob corresponding to the file
  6. 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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants