• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

InDesign UXP Scripting issue : Reading a local file throws permission issue

People's Champ ,
Nov 02, 2022 Nov 02, 2022

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

TOPICS
UXP Scripting

Views

530

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Adobe Employee ,
Nov 03, 2022 Nov 03, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 03, 2022 Nov 03, 2022

Copy link to clipboard

Copied

Hi @Anoop Valomkot 

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:

Capture d’écran 2022-11-03 à 17.58.46.png

 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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Nov 03, 2022 Nov 03, 2022

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.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
People's Champ ,
Nov 03, 2022 Nov 03, 2022

Copy link to clipboard

Copied

LATEST

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

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines