I'm currently working with Github API to make an iOS github client app. I'd like to implement the feature of creating issues with images. My question is how to upload an image for issue comments via API. We're able to upload the image by drag-and-drop via browser in github.com like image below:
I'd like to use this https://cloud.githubusercontent.com/assets/~~~.PNG
.
Any way to upload to https://cloud.githubusercontent.com via API or something?
By the Feb 2020 there are still no official solution to upload files via API to be used in the github issues.
Simple solution is to use a repository branch (you can name it assets
). You can link to them from the github issues easily, just use raw link with last commit SHA:
https://github.com/ORG/REPO/raw/LAST_SHA/PATH
This kind of link will be rendered in the issues body always correctly.
Ever I also try to find one way to make it.But there is not any available method to do it. I'm doing some extra test to find that you can observe the drag-and-drop action in your devtool-network panel.
I find that https://github.com/upload/assets/21842410 be requested with PUT method, and its response is {"id":21842410,"name":"-2.png","size":1261,"content_type":"image/png","href":"https://cloud.githubusercontent.com/assets/3518853/21842410/7c3f6812-d79b-11e6-8209-e49b44aaa883.png","original_name":null}
I've not finished my test, if this inspires you and you have time to implement any demo, please tell me your result. :)
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