getFileForOpening -> initialLocation is ignored

I can’t let the file-picker dialog point at a specific location:

const folder = await fs.getDataFolder()
const file = await fs.getFileForOpening({initialLocation: folder})

Tried it with various folder and file entries, but the open file dialog always starts at the location you previously opened a file from.
The option “initialDomain” works, but is not quite what I need.

I wasn’t sure whether I should post this or not as there are no official docs yet for the file API, but if it’s an unknown bug then this might help I hope.

Docs are here: https://www.adobe.io/photoshop/uxp/uxp/reference-js/Modules/uxp/Persistent%20File%20Storage/FileSystemProvider/#getfileforopeningoptions

What OS are you testing on? The initial location is a suggestion, not a guarantee. On macOS (Big Sur), though, your sample does open a picker with that folder as the default.

Ah nice, I missed the Docs update.

Windows 10 Pro. Maybe some other windows user can confirm that the initialLocation does not work?


I was wondering: What would be the best way (if there’s any at all) to allow the user to provide images that the plugin panel will display? My usecase is that users can save presets (stored in the data-folder) and it would be cool if they could add preview-images. Here are some thoughts of mine:

  • Storing images in the data folder is no option: In HTML/CSS/JS it’s not possible to embed images that are outside of the project root (via img src or background-image)
  • Storing images in the plugin folder… maybe? Is it even possible to alter the contents of the Plugin folder after installation? Or will there be some certification problem like in CEP? Since there’s no command to open the Explorer of the OS, I wanted to either show a prompt with the path or open a file-picker-dialog, so that the user can at least see where the images belong, in case he wants to add preview-images for his presets.
  • You could setup some List UI where the user can link each preset with a remote URL of the image that he uploaded on some image-hoster.

Am I missing an obvious solution?