#File Dialog

11 messages · Page 1 of 1 (latest)

mental leaf
#

I'm trying to open file explorer to select a file and read its contents in JS, but I get Uncaught (in promise) dialog.open not allowed. Plugin did not define its manifest

This is my code so far

const handleOpenFile = async () => {
    const selected = await open({
      multiple: false,
      filters: [{
        name: 'Image',
        extensions: ['png', 'jpeg']
      }]
    });
    if (selected === null) {
      console.log('User Canceled')
    } else {
      console.log('File Selected')
    }
  }

Here's my capabilities default.json

{
  "$schema": "../gen/schemas/desktop-schema.json",
  "identifier": "default",
  "description": "Capability for the main window",
  "windows": ["main"],
  "permissions": [
    "path:default",
    "event:default",
    "window:default",
    "app:default",
    "image:default",
    "resources:default",
    "menu:default",
    "tray:default",
    "shell:allow-open",
    "window:allow-start-dragging",
    "window:allow-close",
    "window:allow-minimize",
    "window:allow-toggle-maximize"
  ]
}

How do I upload files and read the contents, I'm using Tauri V2

fiery dock
#

Generally you're missing the dialog:default and/or dialog:allow-open permission.

#

But the error should be different in this case so make sure your tauri version and dialog plugin version are on their latest versions.

mental leaf
#

I'll try that

fiery dock
#

I just npm installed the dialog plugin
Did you also add the Rust part of the plugin?

mental leaf
#

Because its complaining again

#

This is what I ran
npm install @tauri-apps/plugin-dialog

fiery dock
#

npm run tauri add dialog should work.

If it doesn't then you can cd into src-tauri, run cargo add tauri-plugin-dialog and then modify the lib.rs or main.rs file, like this ```rs
tauri::Builder::default()
// Initialize the plugin
.plugin(tauri_plugin_dialog::init())
.run(tauri::generate_context!())
.expect("error while running tauri application");