AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / computer / 问题 / 1861360
Accepted
RokeJulianLockhart
RokeJulianLockhart
Asked: 2024-11-11 07:43:59 +0800 CST2024-11-11 07:43:59 +0800 CST 2024-11-11 07:43:59 +0800 CST

为什么我不能(或如何)以编程方式访问 GVFS 提供的 URI 的内容?

  • 772
问题摘要

就其本身而言,下面以“上下文”为标题的部分应该向 Stack Overflow 提问。然而,经过进一步诊断,我确定我似乎完全无法applications:/通过 CLI 在 Dolphin 之外访问 URI:

  1. CLI(gio)
    gio list -l applications:/
    
    PS /home/RokeJulianLockhart/Documents/webpage_frontend> gio list -l applications:/                                                     
    gio: applications:/: Operation not supported
    
  2. 海豚

    截屏

为什么会这样?据我所知,这应该可以通过 GVFS 子系统作为虚拟安装访问。但是,它似乎没有被安装:

PS /home/RokeJulianLockhart/Documents/webpage_frontend> gio mount -l              
Mount(0): s11vzd -> file:///run/media/RokeJulianLockhart/s11vzd
  Type: GUnixMount

甚至没有它们的目录:

PS /home/RokeJulianLockhart/Documents/webpage_frontend> tree "$Env:XDG_RUNTIME_DIR/gvfs"
/run/user/1000/gvfs  [error opening dir]

0 directories, 0 files

我猜我肯定做错了什么。但是,我无法确定是什么。

语境

我正在尝试创建一个.JS文件,将 的内容applications:/(可通过 KDE 的Dolphin和 GNOME 的Nautilus文件管理器访问) 输出到一个.HTML文件,以便我可以在Web 浏览器 KDE Plasma 6 plasmashellplasmoid中呈现它。但是,当我连接到服务器 (在http://localhost:3000/index.html) 时,我看到:

<html><head>
    <title>List GVFS Files</title>
</head>
<body>
    <h1>Files in applications:/</h1>
    <div id="fileList"><ol><li>Error accessing GVFS URI: gio: applications:/: Operation not supported</li></ol></div>

    <script>
        async function fetchFiles() {
            try {
                const response = await fetch('http://localhost:3000/list-gvfs-files');
                const fileList = await response.text();

                // Parse and display the file list
                const fileArray = fileList.split('\n').filter(line => line.trim() !== '');
                const listContainer = document.getElementById('fileList');
                const list = document.createElement('ol');
                fileArray.forEach(file => {
                    const listItem = document.createElement('li');
                    listItem.textContent = file;
                    list.appendChild(listItem);
                });
                listContainer.appendChild(list);
            } catch (error) {
                console.error("Error fetching files:", error);
            }
        }

        fetchFiles();
    </script>


</body></html>

具体来说:

访问 GVFS URI 时出错:gio:应用程序:/:操作不受支持

下文中,如果感兴趣的话,我附上了文件的副本:

  1. server.js
    // server.js
    const express = require('express');
    const { exec } = require('child_process');
    const app = express();
    const PORT = 3000;
    
    // Serve static files from the current directory
    app.use(express.static(__dirname));
    
    app.get('/list-gvfs-files', (req, res) => {
        // Check current environment variables
        console.log('Current Environment Variables:', process.env);
    
        // Run the gio command and capture output for debugging
        exec("gio list -l applications:/", (error, stdout, stderr) => {
            if (error) {
                console.error("Command Error:", error);
                console.error("Standard Error:", stderr);
                return res.status(500).send("Error accessing GVFS URI: " + stderr);
            }
    
            console.log("Command Output:", stdout);
            res.send(stdout);
        });
    });
    
    app.listen(PORT, () => {
        console.log(`Server running at http://localhost:${PORT}`);
    });
    
    
  2. index.html
    <!DOCTYPE html>
    <html>
    <head>
        <title>List GVFS Files</title>
    </head>
    <body>
        <h1>Files in applications:/</h1>
        <div id="fileList"></div>
    
        <script>
            async function fetchFiles() {
                try {
                    const response = await fetch('http://localhost:3000/list-gvfs-files');
                    const fileList = await response.text();
    
                    // Parse and display the file list
                    const fileArray = fileList.split('\n').filter(line => line.trim() !== '');
                    const listContainer = document.getElementById('fileList');
                    const list = document.createElement('ol');
                    fileArray.forEach(file => {
                        const listItem = document.createElement('li');
                        listItem.textContent = file;
                        list.appendChild(listItem);
                    });
                    listContainer.appendChild(list);
                } catch (error) {
                    console.error("Error fetching files:", error);
                }
            }
    
            fetchFiles();
        </script>
    </body>
    </html>
    
    

它们都是我根据在线找到的类似主题的信息拼凑起来的(不幸的是,关于这个主题的大多数讨论都涉及 PHP,而我不想使用它,因为我对它更不熟悉)。

gvfs
  • 1 1 个回答
  • 32 Views

1 个回答

  • Voted
  1. Best Answer
    grawity
    2024-11-11T13:30:12+08:002024-11-11T13:30:12+08:00

    它不是 GIO/GVFS 提供的 URI。Dolphin 不以任何方式基于 GNOME 的 GLib2 – 它是使用 Qt 和 KDE 框架编写的,并使用 KDE 对应物KIO来提供虚拟挂载功能。您可能能够kioclient从基于 Qt/KF 的外部应用程序访问它。

    • 2

相关问题

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    如何减少“vmmem”进程的消耗?

    • 11 个回答
  • Marko Smith

    从 Microsoft Stream 下载视频

    • 4 个回答
  • Marko Smith

    Google Chrome DevTools 无法解析 SourceMap:chrome-extension

    • 6 个回答
  • Marko Smith

    Windows 照片查看器因为内存不足而无法运行?

    • 5 个回答
  • Marko Smith

    支持结束后如何激活 WindowsXP?

    • 6 个回答
  • Marko Smith

    远程桌面间歇性冻结

    • 7 个回答
  • Marko Smith

    子网掩码 /32 是什么意思?

    • 6 个回答
  • Marko Smith

    鼠标指针在 Windows 中按下的箭头键上移动?

    • 1 个回答
  • Marko Smith

    VirtualBox 无法以 VERR_NEM_VM_CREATE_FAILED 启动

    • 8 个回答
  • Marko Smith

    应用程序不会出现在 MacBook 的摄像头和麦克风隐私设置中

    • 5 个回答
  • Martin Hope
    Vickel Firefox 不再允许粘贴到 WhatsApp 网页中? 2023-08-18 05:04:35 +0800 CST
  • Martin Hope
    Saaru Lindestøkke 为什么使用 Python 的 tar 库时 tar.xz 文件比 macOS tar 小 15 倍? 2021-03-14 09:37:48 +0800 CST
  • Martin Hope
    CiaranWelsh 如何减少“vmmem”进程的消耗? 2020-06-10 02:06:58 +0800 CST
  • Martin Hope
    Jim Windows 10 搜索未加载,显示空白窗口 2020-02-06 03:28:26 +0800 CST
  • Martin Hope
    andre_ss6 远程桌面间歇性冻结 2019-09-11 12:56:40 +0800 CST
  • Martin Hope
    Riley Carney 为什么在 URL 后面加一个点会删除登录信息? 2019-08-06 10:59:24 +0800 CST
  • Martin Hope
    zdimension 鼠标指针在 Windows 中按下的箭头键上移动? 2019-08-04 06:39:57 +0800 CST
  • Martin Hope
    jonsca 我所有的 Firefox 附加组件突然被禁用了,我该如何重新启用它们? 2019-05-04 17:58:52 +0800 CST
  • Martin Hope
    MCK 是否可以使用文本创建二维码? 2019-04-02 06:32:14 +0800 CST
  • Martin Hope
    SoniEx2 更改 git init 默认分支名称 2019-04-01 06:16:56 +0800 CST

热门标签

windows-10 linux windows microsoft-excel networking ubuntu worksheet-function bash command-line hard-drive

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve