Saving files locally with electron

Adriano picture Adriano · Jun 28, 2016 · Viewed 77.7k times · Source

I have some template files that contain a few variable strings each, I'd like to build a very simple input form with Electron (http://electron.atom.io/) and I want to save the composed output file on the user's computer.

Is there any module I can use to let Electron save files locally?

Answer

Josh picture Josh · Jun 28, 2016

If you are targeting multiple platforms, I answered a similar question here. Basically app.getPath(name), app.setPath(name, path), and app.getAppPath() are very useful in saving files to the the right place regardless of the OS.

You may also want to check out these Nodejs packages which help simplify saving files directly to the host machine...

If you intend for users to save files you might also have a look at the Dialog api where you can specifically invoke a save dialog for that purpose.