I’m finishing migrating my plugin to UXP and I’m wondering how to read and write files with UXP?
With the old CEP version I used to read with JSX the file and parse the string to get the data for the UserPresets, and when the user saved a preset I just read the JSON, parsed it and push a new preset to the array inside the JSON and saved it.
How can it be done in UXP? I don’t understand very well the storage.localFileSystem and tokens workflow, it was really easy to do it in CEP though.
Thanks Anthony, I really don’t have problems with JSON itself but how to create the JSON file and save it in for example the user Documents/ folder. I used to make a folder for my plugin inside the users Documents/ folder and I’m trying to figure out how to do it, how to get the user’s Documents/ path to write a file inside.
perhaps it is easier to use localStorage to store user settings. You can save json there.
But if you want to store settings in a file, then look at the documentation here:
It will be easier to create file in the plugin data folder (getDataFolder). This option does not require user interaction.
To store in an arbitrary location, the user must select a file through a dialog.
Then you need to create a persistent file token for selected file and save it in local storage or data folder.
Using the token, you can perform read/write operations on a file without having to show a dialog box.