JSZipUtils具有承载/令牌认证

时间:2017-10-19 17:15:20

标签: javascript jquery

我想使用JSZipUtils从我的API中提取文件并压缩文件。 API使用令牌身份验证。

但是,我注意到JSZipUtils在library中有基本身份验证硬编码:

if (auth) {
            xhr.setRequestHeader("Authorization", "Basic " + auth);
        }

没有修改他们的代码,有没有人知道如何覆盖它?

1 个答案:

答案 0 :(得分:1)

在技术上不修改代码但覆盖代码的一种解决方案是从源文件复制函数并按照这样做

JSZipUtils.getBinaryContent = function (path, callback, auth){
    //Exactly the same code as in the source file, but with your auth modification
}

这应该在加载原始类之后直接进行。

相关问题