Trouble saving files correctly on Node-Webkit

Get help using Construct 2

Post » Tue Dec 09, 2014 10:41 am

I am currently in the middle of developing a CRM, to be exported using Node-Webkit. I'm quite happy with my progress so far; the application is stable and extremely secure. It uses encryption, input validation (via regex), heavy filesystem expressions, etc.

However, there is one thing which is making part of it very difficult.
At the moment, the way it works is a user logs in and from there, they can choose to enter a new customer's details; once all details are entered, the application pops up a save dialog and allows the user to save the information they have entered as a print-ready XFDF file (Adobe auto-filling PDF). After it is saved, the application opens the file for convenience.

After this is done, a dialog box pops up asking "Do you want to save this customer's information?"
If yes is chosen, the application should automatically save an encrypted file with all the user's information, in a specific folder - formatted ready for viewing as a record in the application later.

The issue I'm facing, is that I cannot find a way to make Node-Webkit save files without the use of the Save dialog. It's important that this is done without letting the user choose the location or name, because the file needs to be saved in a specific folder (with all the rest of the customer files), with a specific name (auto-generated token).

I've tried a few different things including:
-Node-Webkit's 'Write File' action, using a preset path instead of telling it to use the input from the save dialog... nothing happens
-Browser's 'Invoke download of string' action... nothing happens

What's the best way to achieve this?
If I can get this working, it'd also be nice to make the XFDF file save in the background too, in a preset location and with a preset name, etc.
Posts: 6
Reputation: 187

Post » Tue Dec 09, 2014 6:34 pm

If you are using Node-Webkit, try setting the full path to a variable then calling Node.js directly with Browser -> Execute Javascript:

"var fs = require('fs');fs['writeFileSync'](arguments here)"

See the fs syntax here:

I hope this helps.
Posts: 14
Reputation: 328

Post » Tue Dec 09, 2014 7:16 pm

according to the manual ( ... ode-webkit using this link, as there is a bug in the node webkit entry currently), the write file action may let you do this. however, not sure you can create a file everywhere without admin permissions (you should be able to use the user folder, but everything in the program files is no go IIRC)
Game design is all about decomposing the core of your game so it becomes simple instructions.
Posts: 2,122
Reputation: 17,123

Post » Wed Dec 10, 2014 4:22 am

Thanks guys. I'll try that.
Permissions shouldn't be an issue; the end user is fine with running the program with elevated privileges each time.

Love the Colgate, by the way. gg Aphrodite
Posts: 6
Reputation: 187

Return to How do I....?

Who is online

Users browsing this forum: No registered users and 27 guests