Electron Intercept file:///用于读取zip文件内部的协议

时间:2016-09-29 03:53:17

标签: javascript electron

我想用电子邮件阅读内部zip档案,好像它们是文件夹一样,/myfolder/myarchive.zip/picture.jpg。为此,我考虑拦截文件协议

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)})这样的文件似乎也不起作用。

1 个答案:

答案 0 :(得分:0)

看起来这可以通过服务工作者来解决,如下所示:

How to intercept all http requests including form submits

相关问题