I’m late to the party, but I’ve written a third-party discourse-api for nodejs before:
With this library you can easily create uploads. Just do this:
const { DiscourseApi } = require("node-discourse-api");
const api = new DiscourseApi("https://discourse.example.com");
api.options.api_username = "API_USERNAME";
api.options.api_key = "API_KEY";
api.createUpload(file_path_or_buffer, { filename: "filename" })
(Note: This library is not complete)