I was running my extension on Tableau Desktop when I tried to save a local file.
There is no way to save a local file while from an extension in Desktop, however, your users can do this when viewing on Server. Take a look at the Export All extension for an example.
That's kind of what I expected and it's fine. End users will be using the extension on a server. The Desktop functionality would have been more like a nice detail especially during development.