Storage Scheme Differences?

The article below mentions a few different storage schemes but does not explain their differences or use cases, as far as I can tell:

https://developer.adobe.com/photoshop/uxp/2022/uxp/reference-js/Modules/FileSystem/

The starting point of a path in the native filesystem depends on the scheme. UXP supports plugin-specific storage schemes, such as “plugin:”, “plugin-data:”, and “plugin-temp:”, as well as a native “file:” scheme for the path parameter.

They are also mentioned briefly here in a second article:

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

The localFileSystem permission controls access to the user’s local file system. If not specified, the plugin has no access to the user’s file system other than the default access to plugin:// , plugin-temp:// , and plugin-data://

In a third article, I did find more descriptive text, but it does not mention the storage schemes specifically.

https://developer.adobe.com/photoshop/uxp/2022/guides/how-to/#file-io

Files and folders in UXP for Photoshop can exist in four different places:

  • Your plugin’s home directory. Files in this directory are read-only. This is a good place to keep localizations, data files that never change, etc.

  • Your plugin’s data directory. This is a directory managed by UXP which allows read/write access for only your plugin. Files in this directory survive application restarts and OS reboots.

  • Your plugin’s temp directory. This is a place to store session-specific data which will not necessarily persist. You shouldn’t rely on anything in this directory lasting beyond an application restart.

  • The host OS filesystem. Access to specific files or folders in the computer’s filesystem must be requested of the user by your plugin, by showing a file or folder picker. If the user selects a file and does not cancel, your plugin code receives a token which you can use to access that file or folder.

The articles are a bit disjointed and not linked, but I assume they are all referring to the same thing?

1 Like

An explanation on these things would be greatly helpful.

For example, in reference to plugin-data:, “Your plugin’s data directory” isn’t sufficient. I can surmise that its a folder called ‘data’, but relative to what?

I’ve tried MyPlugin/data, and that doesn’t work.
I have a file with path of MyPlugin/data/material-presets/myFile.json and it has some text in it.
This doesn’t work, in my callback function the error is “no such file or directory”:
const paths = await fs.readdir("plugin-data:/material-presets", myCallbackFunc)

If my plugin folder is set up like this:

C:\Photoshop\UXP\MyPlugin
-manifest.json
-index.html
-index.js

What folder would each of the little phrases refer to?

the following entries work without user interactions or special permissions "

// • plugin-temp://
console.log((await fs.getEntryWithUrl("plugin-temp://")).nativePath);
//C:\Users\<username>\AppData\Local\Temp\Adobe\UXP\PluginsStorage\PHSP\24\Developer\<plugin-id>\PluginData

// • plugin-data://
console.log((await fs.getEntryWithUrl("plugin-data://")).nativePath);
//C:\Users\<username>\AppData\Roaming\Adobe\UXP\PluginsStorage\PHSP\24\Developer\<plugin-id>\PluginData

// • plugin://
console.log((await fs.getEntryWithUrl("plugin://")).nativePath)
// plugin folder

while file:// is used with fs.getEntryWithUrl() and require('fs') methods to access files and folder in other places

unrestricted access requires setting permission in the manifest (v5) to fullAccess
or to request and then you can use filer and folder pickers

2 Likes