Equivalent API for github.com/upload/policies/assets for drag-n-drop file upload in PR/Issue comments #29993
Replies: 2 comments 3 replies
-
|
I've tried variations of the following, with no luck: curl -v \
-H "Authorization: Bearer ghp_************************************" \
--data-binary @/tmp/out.svg \
-H "Content-Type: multipart/form-data" \
-H "Referer: https://github.com/mihaigalos/config/pull/2" \
https://api.github.com/repos/mihaigalos/config/issues/2/commentsI'm essentially trying to post an image to a pull request, the same way I would post via drag-and-drop, but via curl in commandline and using a token. The above works for simple text, doesn't work for image upload. Alternatively, since the image is an SVG, I would also be ok to post the content of it and have GitHub render it directly, if possible. |
Beta Was this translation helpful? Give feedback.
-
|
I built gh extension install drogers0/gh-image
IMG=$(gh image banner.png --repo github-community/community)
# => 
Uh oh!
There was an error while loading. Please reload this page.
-
When I drag a file into the comment box in an issue or PR, the front-end app makes a series of requests (beginning with https://github.com/upload/policies/assets) to upload the file to some sort of persistent storage in the back end. I have tried reverse engineering the requests and I can successfully perform the same actions with a little bit of code. But the main limiting factor to using this is the initial request's required use of a cookie. I tried using a PAT but I kept getting 422 responses. Is there an equivalent API in GitHub's public API to upload a file that can be put in a comment?
Beta Was this translation helpful? Give feedback.
All reactions