# Upload avatar image with API

**URL:** <https://meta.discourse.org/t/upload-avatar-image-with-api/55253>\
**Category:** Development\
**Tags:** rest-api\
**Created:** [1월 6, 2017, 1:31오전 UTC](https://meta.discourse.org/t/upload-avatar-image-with-api/55253 "2017-01-06T01:31:43Z")\
**Posts on this page:** 1\
**Showing post:** 12

<div class="post-metadata">

**Author:** ![riking](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/riking/32/170938_2.png) [@riking](https://meta.discourse.org/u/riking)\
**Post date:** [1월 17, 2017, 10:27오후 UTC](https://meta.discourse.org/t/upload-avatar-image-with-api/55253/12 "2017-01-17T22:27:18Z")

</div>

It is, but it’s a very different API.  
Here’s the client code:

> <https://github.com/discourse/message_bus/blob/main/assets/message-bus.js>

It’s possible to implement it in a PHP script for sure. I think I’ve either seen it done or done it myself before (don’t remember which).

Goes something like this:

- start a new thread that posts to the message bus to register
- back in main thread, once that kicks off, start the upload
- 2nd thread loops until it gets the upload id, passes ID back to main thread, exits
- main thread waits to get the ID from the bus thread (could be a thread.join())

---

_[View the full topic](https://meta.discourse.org/t/upload-avatar-image-with-api/55253)._
