File picker not working

I’m simply trying to open a file picker in Photoshop. This used to be simple pre UXP (rant). I used the react-starter from the dev console. My code isn’t opening a file picker.

 const handleGetFiles = async () => {
        const files = await storage.localFileSystem.getFileForOpening({allowMultiple: true, types: fileTypes.images});
        if (files.length === 0) {
            console.log('no files selected');
        }

        console.log('files: ', files);
    }

Are you importing storage and fileTypes correctly?
Try wrapping the code in a try catch block and check if an error is thrown.

I’m importing like this… require('uxp').storage.localFileSystem

Can you point me to the documentation?

const fs = require('uxp').storage.localFileSystem;
const fileTypes = require('uxp').storage.fileTypes;

const handleGetFiles = async () => {
        const files = await fs.getFileForOpening({allowMultiple: true, types: fileTypes.images});
        if (files.length === 0) {
            console.log('no files selected');
        }
        console.log('files: ', files);
    }

Written off the top of my head, but should work. Of course, the handleGetFiles() function needs to be called.

1 Like

I’m using your code example and the handleGetFiles function is being called… Still not opening a file picker window.

I’ve unloaded the plugin and reloaded.

Tested the code and it works. Probably your problem is somewhere else …

The manifest needed to be updated to include this line:

"localFileSystem": "fullAccess",

It needs to be mentioned that this is only required for a manifest version >= 5.
And I think for this operation "localFileSystem": "request" is sufficient.

Documentation: https://developer.adobe.com/photoshop/uxp/2022/guides/uxp_guide/uxp-misc/manifest-v5/#local-filesystem

it is enough for file/folder pickers
however full access is required for getEntryWithUrl (no user interaction!) and require('fs') operations