2017-10-19 120 views
1

我想使用JSZipUtils从我的API中提取文件并压缩文件。该API使用令牌认证。带有承载/令牌认证的JSZipUtils

不过,我注意到JSZipUtils在其library基本身份验证硬编码:

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

无需修改自己的代码,没有人知道如何重写?

回答

1

一个解决方案,你在技术上没有修改自己的代码,但覆盖它,是在装载原班后的功能从源文件复制,做这样的

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

这应该是直接。