How to upload files through the API?

Here is a node example that someone got working that might help: