Trilium Electron API
    Preparing search index...

    Interface ElectronNativeImportApi

    Desktop-native import that reads the user's file in place (bounded memory, no temp copy) — the whole point being multi-GB .zip archives, though any importable file is accepted. The renderer never handles a filesystem path: pickFiles runs the OS dialog in the main process and returns opaque capability tokens, which importFromToken redeems. A script can't forge a token or pass a path, so it can never read an arbitrary file.

    interface ElectronNativeImportApi {
        grantDroppedFiles(files: File[]): Promise<NativeImportPickResult>;
        importFromToken(
            opts: {
                format?: string;
                last: boolean;
                options: NativeImportOptions;
                parentNoteId: string;
                taskId: string;
                token: string;
            },
        ): Promise<NativeImportResult>;
        pickFiles(): Promise<NativeImportPickResult>;
    }
    Index
    • Resolves files the user dropped onto a drop zone to capability tokens, so a drag-and-drop import takes the same in-place (streamed) path as the dialog. The File is the unforgeable capability: the path is obtained via webUtils.getPathForFile, which yields a real path only for a genuinely user-supplied file and an empty string for anything a script constructed — so a script can't smuggle in an arbitrary path. Returns cancelled when no dropped file resolved (e.g. dragged from a browser, not the OS), so the caller falls back to the normal upload route.

      Parameters

      • files: File[]

      Returns Promise<NativeImportPickResult>

    • Imports the file behind token into parentNoteId. Progress/success/error are reported over the WebSocket via taskId, matching the HTTP import path. When importing several files in one batch, set last only on the final call so the success toast fires once, after everything is in. format routes the file to a specific importer (e.g. "obsidian"), mirroring the HTTP route's format tag.

      Parameters

      • opts: {
            format?: string;
            last: boolean;
            options: NativeImportOptions;
            parentNoteId: string;
            taskId: string;
            token: string;
        }

      Returns Promise<NativeImportResult>

    • Prompts a native "open file" dialog (multi-select, any type) and returns single-use tokens for the chosen files.

      Returns Promise<NativeImportPickResult>