Copy link to clipboard
Copied
Hi there,
I was just trying to read a local file with UXP Scripting in an InDesign Script. But I get a permission error which I partially understand (i.e. accessing files is now under restrictions). However UXP Scripting docs claim that files can be accessed "freely" in some specific folders (the plugin folder for example).
But no matter if I place the file to be read next to the idjs script, I can't pass through the permission error.
Has someone a clearer set of instructions for reading files when it comes to UXP Scripting and InDesign specifically?
Loic
Copy link to clipboard
Copied
@Loic.Aigon Please share details on the API you are using for accessing the file and also the file paths involved.
Copy link to clipboard
Copied
I was trying to use the standard node fs.readFileSync with a file onto my desktop at first :
const fs = require("fs");
var data = fs.readFileSync("/Users/ozalto/Desktop/face.png");
and got the following warning:
Which I thought was related to the permission paradygm. So I place the file next to the script in th scripts folder and run:
const fs = require("fs");
var data = fs.readFileSync("/Users/ozalto/Library/Preferences/Adobe InDesign/Version 18.0/fr_FR/Scripts/Scripts Panel/face.png");
But got the same issue.
If I try to use the tempFolder:
const folder = await ufs.getTemporaryFolder();
const path = await ufs.getNativePath(folder);
And place my file there, same issue.
The main idea here is to read a temporary file a script could output but I am failing to do so. So either I am missing the obvious or hitting a wall, I can't tell.
Feel free to let me know if I am chasing cars here.
Loic
Copy link to clipboard
Copied
Hi Loic. I've been able to read and write files anywhere in Windows. One thing to remember is that (so far( UXP doesn't have a File object. To save an indd somehwere, instead of
myIndd.save (File ('d:/dir1/dir2/test.indd'));
(which you use in ExtendScript) now in UXP you pass through a string:
myIndd.save ('d:/dir1/dir2/test.indd');
Does that help?
P.
Copy link to clipboard
Copied
Hi Peter,
Thanks for the suggestion. It's more about trying to read a temporary file in an intermediate process of a larger script. Could be some txt file for ex.
Best regards,
Loic