"Route not found" error

Hello.

I’m getting a “Route not found” error when trying to copy a file to the data folder. Any idea why that happens?

Here’s the function …

async function importPresets() {
  try {
    let datafolder = await fs.getDataFolder();
    let importfile = await fs.getFileForOpening({types: ["json"]});

    if(importfile) {
      await importfile.copyTo(datafolder, {overwrite:true});
      if(await loadPresetFile()) {
        document.getElementById("dropdown_presets").firstElementChild.innerHTML = "" ;
        presetArray.forEach(await function(presets) {
          document.getElementById("dropdown_presets").firstElementChild.innerHTML += "<sp-menu-item >" + presets.name + "</sp-menu-item>";
        });
        document.getElementById("dropdown_presets").selectedIndex = 0;
        await updateUI(0);
        return true;
      }
    }
  } catch(error) {
    return false;
  }
}

I’ve encountered a similar problem, and this thread is the first one that pops up when searching for the error.

My manifest.json does contain fullAccess for the localFileSystem:

	"requiredPermissions": {
		"localFileSystem": "fullAccess",

Photoshop version 26.8.0

This is the trace in the console:

/assets/index-D1WwMQU7.js:1951 Error: Route not found
    at e.exports.readdir (uxp://uxp-internal/webfs_scripts.js:2)
    at uxp://uxp-internal/webfs_scripts.js:2
    at uxp://uxp-internal/webfs_scripts.js:2
    at new Promise (<anonymous>)
    at n (uxp://uxp-internal/webfs_scripts.js:2)
    at m (uxp://uxp-internal/webfs_scripts.js:2)
    at Object.readdir (uxp://uxp-internal/webfs_scripts.js:2)

I’ve played around and tried the following variations (path is copy pasted from the windows file explorer, so this directory does exist):

fs.readdir("file:///C:/Users/User/Desktop")
fs.readdir("file://C:/Users/User/Desktop")
fs.readdir("file:C:/Users/User/Desktop")
fs.readdir("C:/Users/User/Desktop")

I’ve also attempted using storage.localFileSystem.getFolder and taking the resulting nativePath from the Entry, with no luck:

const entry = await storage.localFileSystem.getFolder()
const location = entry.nativePath

// tried both approaches
fs.readdir(location)
fs.readdir(`file:${location}`)

Interestingly enough, the following does work:

const entry = await storage.localFileSystem.getFolder()
const location = entry.url
fs.readdir(location)

Any help with this would be greatly appreciated :folded_hands:

Looks like it was the version of Adobe Photoshop I was running.

Noticed BUG: FS File Protocol -4058 path Error after Photoshop 26.8 - #6 by justin2taylor and updating fixed the issue. the fs.readdir examples at the top of my reply now work.

1 Like