[Bug report] fs.getFileForSaving()

Hi, I’m trying to use the fs.getFileForSaving() but it doesn’t work!

I’m on win 10 here the sample code:

var fs = require("uxp").storage.localFileSystem;
const [file] = await fs.getFileForSaving({ types: [ "txt" ]});
if (!file) {
await file.write("It was a dark and stormy night");

Here the console log errors:

Plugin TypeError: a.lastIndexOf is not a function
    at b.<anonymous> (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/torq-2.1-xd-13.0/build/modules_gen/webfs/src/js/webfs_scripts.js:134:2139)
    at new Promise (<anonymous>)
    at b.value (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/torq-2.1-xd-13.0/build/modules_gen/webfs/src/js/webfs_scripts.js:134:1868)
    at b.<anonymous> (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/torq-2.1-xd-13.0/build/modules_gen/webfs/src/js/webfs_scripts.js:138:1937)
    at new Promise (<anonymous>)
    at b.value (uxp://uxp-internal/home/ubuntu/jenkins/workspace/Torq/torq-native/torq-2.1-xd-13.0/build/modules_gen/webfs/src/js/webfs_scripts.js:138:1753)
    at blueRectangle (\main.js:41:29)
    at Object.execScenegraphEdit (plugins/ScenegraphGuard.js:1:2219)
    at BaseCommand._invokePluginCommand [as _commandFn] (plugins/PluginLoader.js:1:2980)
    at BaseCommand.execute (lib/BaseCommand.js:1:929)

I just copied and pasted the sample code from the official doc.

UPDATE: it doesn’t work either on mac os…

We’re in the process of updating the docs here – please try:

const file = await fs.getFileForSaving("yourFile.txt", {types: ["txt"]});

For reference, this is due to the following breaking change listed in the release notes for the 13.0.11 prerelease build:

  • getFileForOpening() returns a File instead of an array if allowMultiple is false (the default value).

So you no longer need the array destructuring ([file] = ...) if you’re only letting the user pick a single file.

That’s a very thorough process you must be going through here. Can’t wait until it’s finished. :crazy_face: