Add the ability to download raw file, needed when size > 1MB #1075
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
API DOC https://docs.github.com/en/rest/repos/contents
The API call to return the content of a file return an empty content if a file is bigger than 1MB.
To be able to download that file, we need to provide the header
application/vnd.github.VERSION.raw
.When doing so, the API return a the raw file, instead of a JSON object with some attributes + the file content.
Because the API has a different behavior, I preferred to create a dedicated method as opposed to provide accept more option in the download method and having a bunch of if/else.
Note: a 3rd behavior exists for that API call when downloading markdown and passing the
application/vnd.github.VERSION.html
header, which is not supported by this code change.