Create an issue with image via GitHub API
Asked Answered
S

1

24

I am creating issues with https://developer.github.com/v3/issues/#create-an-issue. Is it possible to attach images to message body?

I tried 'Accept', 'application/vnd.github.v3.html+json'and emmbeded the image as img elment base64 encoded. The image will not show, but the ticket editor shows the img element.

Spratt answered 24/2, 2015 at 18:31 Comment(1)
There's currently no way to upload images like you would when filing a comment through the Web UIAvilla
U
11

There is no simple solution to this. The official docs say nothing about that which means it's not supported.

The GitHub.com authentication works based on cookies while the API authentication uses tokens/passwords. That means if you really want to hack the things to upload your image using GitHub, you have to login using a cookie which is probably more difficult than using a third-party image hosting website.

For example, you could just upload your image to imgur and then add it in the issue body:

![image-title](http://i.imgur.com/x....xx.png)

This will anyway be proxied by GitHub proxy and will be served offer HTTPs.

Unbated answered 4/10, 2015 at 12:47 Comment(6)
To avoid using another provider (imgur) you could also upload the image to a bot reporter's github repository (created just for that).Marqueritemarques
Hi, @Marqueritemarques could you elaborate, please?Ecclesiolatry
@ArturoMejia: Sure. Nothing fancy: 1) Create a new github account. 2) Profile -> Developer Settings -> Personal access tokens. Generate a token for scope repo -> public_repo. 3) Now you can upload files (so also images) to this repo and link them in the issue of any other repo.Marqueritemarques
I just remember I had this uploaded: gist.github.com/tokland/15c3fd136c0e8fd547db32ad72ab045aMarqueritemarques
@Marqueritemarques I created a base64 image file in my repo. however, the file can't be displayed from the download. It still shows as base64 when I open the file.Mufinella
Never mind. I figured it out. convertContentToBase64 need to set as false when using Octokit libraryMufinella

© 2022 - 2024 — McMap. All rights reserved.