Upload files (real-time API)

While the call to the sendMessage method was fairly straightforward, the documentation for uploading a file is sketchy, and possibly incomplete. I looked for information on forums or tried to make sense of the code, but without success.

What I understand is that

  1. a slingshot/uploadRequest method must be invoked.
  2. the response must be used to
  3. call the sendFileMessage

But it is unclear which information from the response must be used in the sendFileMessage and how. In particular, when is the actual file information (the content) actually uploaded?

Could someone give a real-life example of these three messages, possibly with some explanation of the semantics, and how the fields should fit together?

For info, I am working on a python implementation based on python-meteor, taking the cue from python-rocketchat-bot. So far the bot can subscribe, receive messages, answer, and even download files (I had to use a normal https call, with cookies)