How exactly does OnionShare work to allow one to send files using onion domains?
OnionShare allows you to share files over onions, it will allow you to offer them to other users for download.
It packages a lightweight, native python httpd called Flask. When you start OnionShare, you provide it a list of files you want to share, it loads the files into a single zip file and uses a simple page template with a link to the zip file and then starts the httpd on some high numbered port to serve the page and zip file to the visitor(s).
It uses the stem library to connect to a running Tor's control port, trying each of the common ports in turn if it is not explicitly defined in the users environment. It then uses the
ADD_ONION method to create an ephemeral hidden service if the Tor version is >=2.7.1 (when the functionality was added) otherwise it create a temporary directory and configures it as the place to store the information associated with the onion service.
Once it has successfully published the newly generated onion service it performs a self-connectivity test to ensure that it is able to reach the onion over Tor and if it's successful it will provide you with a link to give other users, from which they can download the zipped up set of files you wanted to share.