Is it possible to post binary files (such as images) to GitHub gists via the HTTP api?
In particular, the Gist api docs describe how to post files with string contents. There are two problems here for uploading images. One is that the api has something like a 64kb limit on POST requests (although this is not documented), which is pretty small for image files. Second, it's not obvious what encoding should be used on the wire for image files.
It's easy to do this by cloning the git repository associated with the Gist, adding the file, and pushing to the repository, but that requires git and I'd like to make this work on systems without git installed.
For uploading the file into GitHub you can go through basic steps: Get the file content using 'fs' module. Encode the content into base64 format. then use GitHub API “https://api.github.com/repos/{owner}/{repo}/contents/{file name}”.
The response I received from GitHub is that they don't intend to support posting binary files to Gists via the HTTP API, sadly.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With