gpt4 book ai didi

javascript - Electron 拦截文件 :///protocol to read inside zip files

转载 作者:数据小太阳 更新时间:2023-10-29 05:37:47 26 4
gpt4 key购买 nike

我想用 Electron 阅读内部的 zip 文件,就好像它们是文件夹一样,比如 /myfolder/myarchive.zip/picture.jpg。为此,我正在考虑拦截文件协议(protocol)

protocol.interceptFileProtocol('file', (request, callback) => {
if (insideZipArchive) {
//respond with zip file contents
} else {
//defaultBehavior
}

}, (error) => {
if (error) console.error('Failed to register protocol')
})

如何调用默认行为?同样在拦截器内部执行 AJAX 请求并提供像这样的文件 callback({data: new Buffer(xhr.responseText)}) 似乎不起作用。

最佳答案

看起来这可以通过 service worker 来解决,如下所示:

How to intercept all http requests including form submits

关于javascript - Electron 拦截文件 :///protocol to read inside zip files,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39761115/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com