In order to understand the implementation of any feature in the default framework, the best way is to simply look at the sources (you can find how upload files... works simply by searching for it in the code-base).
The idea is to:
create a command
implement the execute callback (which does the actual work of the command itself)
register the command with a uriAwareCommandHandler (so it knows about resource URI selections)
register the context menu (ex: the file context-menu)