shawn
March 2, 2023, 8:51pm
1
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);
}
tomzag
March 2, 2023, 9:13pm
2
Are you importing storage
and fileTypes
correctly?
Try wrapping the code in a try catch
block and check if an error is thrown.
shawn
March 2, 2023, 9:23pm
3
I’m importing like this… require('uxp').storage.localFileSystem
shawn
March 2, 2023, 9:26pm
4
Can you point me to the documentation?
tomzag
March 2, 2023, 9:31pm
5
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
shawn
March 2, 2023, 9:37pm
6
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.
tomzag
March 2, 2023, 9:59pm
7
Tested the code and it works. Probably your problem is somewhere else …
shawn
March 2, 2023, 10:31pm
8
The manifest needed to be updated to include this line:
"localFileSystem": "fullAccess",
tomzag
March 3, 2023, 8:10am
9
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
Maher
March 3, 2023, 9:25am
10
it is enough for file/folder pickers
however full access is required for getEntryWithUrl
(no user interaction!) and require('fs')
operations