enable upload image data over the API

This allows people to use the API to upload image files which are then stored on the server.

The code here is somewhat similar to that used in the UI but there's enough differences that trying to use the same code in each look like introducing quite a lot of complexity for limited gain.