UXP - Open document without dialog

Hello,

I am trying to create function that would open document without dialog, directly from path which will be given as argument.

Can anyone advise why this doesn’t work?


async function openFile(psd_path){
    const app = require('photoshop').app;

    try {
        console.log(psd_path)
        await app.open(`${psd_path}`);

    } catch (error) {
        console.error('Error:', error);
        throw error;
    }

}

You need to pass a ‘file entry’ (as described here) to the open function, not a file path. You can obtain a file entry either by displaying a dialog and ask the user to grant access to the file you want to open or by adding the right permissions to your manifest file and using getEntryWithUrl, as described here.