2

Is there a way to create a gist using curl and the Github gist REST API, so that a binary file can be uploaded (for example and image file, or a zip)? I'm mainly interested in being able to upload an SVG file, but I'm also curious as to how it should look for a PNG, or JPEG. I have the following code so far, which works fine for text files:

curl \
  -H "Accept: application/vnd.github+json" \
  -H "Authorization: token ${GITHUB_TOKEN"} \
  https://api.github.com/gists \
  -d '{"description":"test-repo-issue-123-20220811-221420","public":false,"files":{"README.md":{"content":"This is a text file."}}}'

But... how would one pass a binary file here? How does it have to be encoded?

How would it look like if it were for an SVG file?

carlspring
  • 31,231
  • 29
  • 115
  • 197
  • 1
    One possibility is that each gist has an associated git repo with it, and you can add images to that like this: https://stackoverflow.com/a/43150165/530160 Still need to create the gist in the first place, though. – Nick ODell Aug 12 '22 at 01:19

0 Answers0