Is there an Adobe-supported method to store user inputs/filepaths via Photoshop UXP?

I’m trying to save user-specified filepaths for later use in my Photoshop plugin. Is there any standard way in UXP to do this? One which Adobe actively supports? For example, if you were building a Chrome Extension, you can just Chrome Storage to store any number of things in memory for later use. Is there something comparable in UXP?

From what I’ve seen/can tell, it seems that for users to specify a folder/filepath, they need to literally use the filepicker each time to specify it. Then you apparently need to pass that filepath into an intermediary method that converts it into a token – and only when you have this token can you use the filepath for your needs (open this document; use this image for the background layer; etc). Then I also read elsewhere in Photoshop documentation that this token doesn’t even persist across plugin sessions.

All of that seems to indicate to me, that unless I’m wrong, there isn’t any kind of Adobe-supported method that would allow you to store user-specified filepaths like this to simplify workflows for users via your plugin – and instead, they want users to actively specify the filepaths each and every time an operation needs to take place.

Perhaps (and hopefully) I’m wrong about that. If you’re writing a jsx script for yourself, you would be able to fully automate your workflow by just specifying the filepaths you need to open, the various images to use at different parts, the output folder to save the final results to, etc. But if we can’t save any of these user-specified filepaths, it seems that there’s just not going to be any kind of an effective way to make things more convenient for plugin users by storing that info for later use.

Thanks!

Adobe has provided the getDataFolder for this purpose.

const pluginDataFolder = await fs.getDataFolder();

With this it is also not necessary to implement a file dialog.

Another possibility is also localStorage. Kerri wrote about the differences here.

1 Like

Can I use this local storage approach to store, then re-use, folder/filepaths in later operations, without forcing users to re-select it each time?

So let’s say I want to give the user an option, in my plugin, to save certain workflows for re-use as needed. For example, imagine someone has a standard company logo they need to apply as a watermark to 1000 images. Instead of forcing them to use the filepicker to pick the logo each and every time they need to run this operation, via that UXP method – could I instead collect this information once, then push that filepath into local storage (stored as variable name UserWatermarkLogo or something like that) – then give the user a functionality to re-run this operation, where it would then pull that filepath from storage and use it in that UXP code? Could I re-use the filepaths that way?

I ask because, the “token” approach to opening files makes it seem like, Adobe might be trying to actively discourage storing any kind of filepath info via your plugin. I may be completely wrong about that however.

Yes you can. For these purposes you can create/save/load persistent tokens.

1 Like

Gotcha. Looks like literally exactly what I’m going for.

Another question on this: Is there any risk of local storage (or that other method) getting wiped? Like with updates? Or if the user clears their cache in Photoshop settings? Or is this plugin specific, and so long as the plugin is installed, the data stored there will continue to persist?

Both stores are plugin specific and should remain between updates.

They are removed when:

  • the plugin is uninstalled
  • or the files are removed manually / by another process.
1 Like

Excellent, straightforward answers. Thanks for your help!