-
-
Notifications
You must be signed in to change notification settings - Fork 30
Description
When a file is larger than 1MB, the content field is an empty string when you try to update an existing file:
// updates file based on current content
"path/to/file4.txt": ({ exists, encoding, content, size }) => {
// do not create the file if it does not exist
if (!exists) return null;
// content === '', encoding === 'none', size === 1240000
},There are some details in the docs about the GET /repos/{owner}/{repo}/contents/{path} endpoint that is used in createTree that explain what is going wrong here:
If the requested file's size is:
- 1 MB or smaller: All features of this endpoint are supported.
- Between 1-100 MB: Only the raw or object custom media types are supported. Both will work as normal, except that when using the object media type, the content field will be an empty string and the encoding field will be "none". To get the contents of these larger files, use the raw media type.
- Greater than 100 MB: This endpoint is not supported.
It seems like what's happening is that the request is defaulting to use Accept: application/vnd.github.object+json header. But when the file is larger than 1MB, it should recognize this by reading the size property, and then calling the endpoint again with Accept: application/vnd.github.raw+json to get the full contents.
My current workaround is to do this extra request in my own code to get the file contents, but I feel like this could be handled by this library internally