If you go to your Profile Activity page here, you will see a “Download All” button. When you click it and confirm, there is a modal that displays letting you know that the server-side process was initiated.
When the process is complete, Discourse gives you a Notification of the Message that contains the download link
IMHO, this approach works very well.