Skip to content

Note for 17th Dec 2018 at 12:00pm

Published by Vincent Pickering
on

Last night I managed to successfully implement another IndieWeb feature a Media endpoint to the blog.

A Media endpoint allows you to upload data to your website, usually in practice it is used for photo posts but you could use it to upload files if you wished. This will now give me the option to post images here on the blog instead of Instagram, which I would like to quit using.

In practice it wasn’t as complicated as I thought it might be to implement. This is how it works.

  1. The endpoint needs to authenticate with IndieAuth.
  2. Once authenticated it accepts an image URL encoded, as per spec.
  3. The image is stored in memory.
  4. The code then responds to the file sender with a location for where the image will be located.
  5. The image is then base 64 encoded and POST’ed in to the Github API with a unique filename.
  6. The endpoint returns complete.

The Sender acquires the file location for the photo and runs through it sequentially for multiple photos. It then sends the location string(s) along with the other JSON data.

I extended my note formatter to accommodate photos and output the photo location and alternate text for each image in to the Frontmatter for the post.