# Upload images from Github .md file using Discourse API

**URL:** <https://meta.discourse.org/t/upload-images-from-github-md-file-using-discourse-api/198661>\
**Category:** Development\
**Created:** [July 30, 2021, 10:42am UTC](https://meta.discourse.org/t/upload-images-from-github-md-file-using-discourse-api/198661 "2021-07-30T10:42:18Z")\
**Posts on this page:** 1\
**Showing post:** 1

<div class="post-metadata">

**Author:** ![marielavd](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/marielavd/32/215907_2.png) [@marielavd](https://meta.discourse.org/u/marielavd)\
**Post date:** [July 30, 2021, 10:42am UTC](https://meta.discourse.org/t/upload-images-from-github-md-file-using-discourse-api/198661/1 "2021-07-30T10:42:18Z")

</div>

Hi all,

I use a Node.js workflow to connect Github repository and Discourse through Discourse API.  
Every time someone pushes .md file in a repository automatically Discourse topic is created using POST request https://{defaultHost}/posts.json or if the topic already exits - I just update it with PUT request https://{defaultHost}/posts/{id}.json.

I have a problem with the images - there is couple of ways to include image in Github .md file. The following are working fine and the images are uploaded to Discourse:

- if the image is hosted on [https://user-images.githubusercontent.com/](https://user-images.githubusercontent.com/)
- if the image is uploaded directly to the repo and you append a ?raw=true at the end of the image link  
[https://github.com/[username]/[reponame]/blob/[branch]/image.jpg?raw=true](https://github.com/%5Busername%5D/%5Breponame%5D/blob/%5Bbranch%5D/image.jpg?raw=true)

but the following two are not working:

- if relative link is used  
relative/path/to/img.jpg  
 ![chrome_AlKPWqujmu](https://global.discourse-cdn.com/meta/original/3X/1/1/115efa328ec79f0ecf037927afa35683f13ba28c.png)
- the ?raw=true part is missing  
[https://github.com/[username]/[reponame]/blob/[branch]/image.jpg](https://github.com/%5Busername%5D/%5Breponame%5D/blob/%5Bbranch%5D/image.jpg)  
 ![chrome_HMXKFyfVtL](https://global.discourse-cdn.com/meta/original/3X/5/5/55f138eb7ea71ae474022e44d309932ab878ccfa.png)

Is there a way to ensure that all the images from the .md file will be uploaded to Discourse?

---

_[View the full topic](https://meta.discourse.org/t/upload-images-from-github-md-file-using-discourse-api/198661)._
