How to upload a file via API and get it's URL?

See Reverse engineer the Discourse API